VideoInfoServiceImpl.java 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. package top.lvzhiqiang.service.impl;
  2. import com.github.pagehelper.PageHelper;
  3. import com.github.pagehelper.PageInfo;
  4. import org.springframework.beans.factory.annotation.Value;
  5. import org.springframework.stereotype.Service;
  6. import top.lvzhiqiang.config.WebAppConfig;
  7. import top.lvzhiqiang.entity.VideoGenres;
  8. import top.lvzhiqiang.entity.VideoInfo;
  9. import top.lvzhiqiang.entity.VideoInfoOther;
  10. import top.lvzhiqiang.mapper.*;
  11. import top.lvzhiqiang.service.VideoInfoService;
  12. import top.lvzhiqiang.util.MarkdownToHtmlUtils;
  13. import top.lvzhiqiang.util.StringUtils;
  14. import javax.annotation.Resource;
  15. import java.io.File;
  16. import java.util.Comparator;
  17. import java.util.List;
  18. import java.util.Map;
  19. /**
  20. * 电影信息ServiceImpl
  21. *
  22. * @author lvzhiqiang
  23. * 2022/4/4 15:28
  24. */
  25. @Service
  26. public class VideoInfoServiceImpl extends BaseServiceImpl<Object> implements VideoInfoService {
  27. @Resource
  28. private VideoInfoMapper videoInfoMapper;
  29. @Resource
  30. private VideoInfoPoolMapper videoInfoPoolMapper;
  31. @Resource
  32. private VideoInfoUncensoredMapper videoInfoUncensoredMapper;
  33. @Resource
  34. private VideoInfoInfantryMapper videoInfoInfantryMapper;
  35. @Resource
  36. private CrawlerLoveFootMapper crawlerLoveFootMapper;
  37. @Resource
  38. private VideoInfoOtherMapper videoInfoOtherMapper;
  39. @Value("${spring.profiles.active}")
  40. private String env;
  41. /**
  42. * 查询所有
  43. *
  44. * @return
  45. */
  46. @Override
  47. public List<VideoInfo> findAll() {
  48. return videoInfoMapper.findAll();
  49. }
  50. /**
  51. * 分页查询所有
  52. *
  53. * @return
  54. */
  55. @Override
  56. public PageInfo<VideoInfo> findAll(int pageNo, int pageSize) {
  57. PageHelper.startPage(pageNo, pageSize);
  58. List<VideoInfo> videoInfoList = videoInfoMapper.findAll();
  59. PageInfo<VideoInfo> videoInfoPageInfo = new PageInfo<>(videoInfoList);
  60. return videoInfoPageInfo;
  61. }
  62. @Override
  63. public PageInfo<VideoInfo> getVideoInfoPage(Map<String, Object> params) {
  64. Object bigType = params.get("bigType");
  65. List<VideoInfo> videoInfoList;
  66. // 转换成like
  67. paramsToLike(params, "keyword");
  68. // 分页
  69. paramsToPagination(params);
  70. // 排序
  71. if ("骑兵".equals(bigType)) {
  72. paramsToSort2(params,"vi.identification_code desc");
  73. videoInfoList = videoInfoMapper.getVideoInfoList(params);
  74. } else if ("步兵".equals(bigType)) {
  75. Object genres = params.get("genres");
  76. paramsToSort(params);
  77. if (null == genres) {
  78. List<VideoGenres> videoGenresList = videoInfoInfantryMapper.findGenres();
  79. params.put("genres", videoGenresList.get(0).getName());
  80. }
  81. videoInfoList = videoInfoInfantryMapper.getVideoInfoInfantryList(params);
  82. } else if ("流出".equals(bigType)) {
  83. paramsToSort(params);
  84. videoInfoList = videoInfoUncensoredMapper.getVideoInfoUncensoredList(params);
  85. } else if ("码池".equals(bigType)) {
  86. paramsToSort2(params, "vi.identification_code desc");
  87. videoInfoList = videoInfoPoolMapper.getVideoInfoPoolList(params);
  88. } else if ("足舐".equals(bigType)) {
  89. paramsToSort2(params, "vi.identification_code desc");
  90. videoInfoList = crawlerLoveFootMapper.getVideoInfoLoveFootList(params);
  91. } else {
  92. paramsToSort(params);
  93. videoInfoList = videoInfoMapper.getVideoInfoList(params);
  94. }
  95. PageInfo<VideoInfo> videoInfoPageInfo = new PageInfo<>(videoInfoList);
  96. return videoInfoPageInfo;
  97. }
  98. /**
  99. * 影片信息详情
  100. *
  101. * @param type
  102. * @param code
  103. * @return
  104. */
  105. @Override
  106. public VideoInfo getVideoInfoDetail(String type, String code) {
  107. VideoInfo videoInfo;
  108. if ("qibing".equals(type)) {
  109. videoInfo = videoInfoMapper.getVideoInfoDetail(code);
  110. if (videoInfo == null) {
  111. return null;
  112. }
  113. String qibingPath = WebAppConfig.dicCodeList.stream().filter(x -> 1 == x.getType() && env.equals(x.getEnv()) && "apics_path".equals(x.getCodeKey())).findFirst().get().getCodeValue();
  114. String imgPrefixGFPath = "骑兵/".concat(videoInfo.getIdentificationCode()).concat("/img_gf/");
  115. String imgPrefixSYPath = "骑兵/".concat(videoInfo.getIdentificationCode()).concat("/img_sy/");
  116. videoInfo.setImgPrefixGFPath(imgPrefixGFPath);
  117. videoInfo.setImgPrefixSYPath(imgPrefixSYPath);
  118. // 获取样品图像-官方
  119. File imgGFFile = new File(qibingPath, imgPrefixGFPath);
  120. if (imgGFFile.exists()) {
  121. File[] files = imgGFFile.listFiles();
  122. for (File file : files) {
  123. videoInfo.getImgGFList().add(file.getName());
  124. }
  125. videoInfo.getImgGFList().sort(Comparator.naturalOrder());
  126. }
  127. // 获取样品图像-私有
  128. File imgSYFile = new File(qibingPath, imgPrefixSYPath);
  129. if (imgSYFile.exists()) {
  130. File[] files = imgSYFile.listFiles();
  131. for (File file : files) {
  132. videoInfo.getImgSYList().add(file.getName());
  133. }
  134. videoInfo.getImgSYList().sort(Comparator.naturalOrder());
  135. }
  136. videoInfo.setCommentFirst(MarkdownToHtmlUtils.markdownToHtmlExtensions(videoInfo.getCommentFirst()));
  137. videoInfo.setComment(MarkdownToHtmlUtils.markdownToHtmlExtensions(videoInfo.getComment()));
  138. videoInfo.setCommentXp(MarkdownToHtmlUtils.markdownToHtmlExtensions(videoInfo.getCommentXp()));
  139. } else if ("bubing".equals(type)) {
  140. videoInfo = videoInfoInfantryMapper.getVideoInfoDetail(code);
  141. if (videoInfo == null) {
  142. return null;
  143. }
  144. String bubingPath = WebAppConfig.dicCodeList.stream().filter(x -> 1 == x.getType() && env.equals(x.getEnv()) && "apics_path".equals(x.getCodeKey())).findFirst().get().getCodeValue();
  145. String imgPrefixGFPath = "步兵/".concat(videoInfo.getInfantryType()).concat("/").concat(videoInfo.getIdentificationCode()).concat("/img_gf/");
  146. String imgPrefixSYPath = "步兵/".concat(videoInfo.getInfantryType()).concat("/").concat(videoInfo.getIdentificationCode()).concat("/img_sy/");
  147. videoInfo.setImgPrefixGFPath(imgPrefixGFPath);
  148. videoInfo.setImgPrefixSYPath(imgPrefixSYPath);
  149. // 获取样品图像-官方
  150. File imgGFFile = new File(bubingPath, imgPrefixGFPath);
  151. if (imgGFFile.exists()) {
  152. File[] files = imgGFFile.listFiles();
  153. for (File file : files) {
  154. videoInfo.getImgGFList().add(file.getName());
  155. }
  156. videoInfo.getImgGFList().sort(Comparator.naturalOrder());
  157. }
  158. // 获取样品图像-私有
  159. File imgSYFile = new File(bubingPath, imgPrefixSYPath);
  160. if (imgSYFile.exists()) {
  161. File[] files = imgSYFile.listFiles();
  162. for (File file : files) {
  163. videoInfo.getImgSYList().add(file.getName());
  164. }
  165. videoInfo.getImgSYList().sort(Comparator.naturalOrder());
  166. }
  167. } else if ("liuchu".equals(type)) {
  168. videoInfo = videoInfoUncensoredMapper.getVideoInfoDetail(code);
  169. if (videoInfo == null) {
  170. return null;
  171. }
  172. String bubingPath = WebAppConfig.dicCodeList.stream().filter(x -> 1 == x.getType() && env.equals(x.getEnv()) && "apics_path".equals(x.getCodeKey())).findFirst().get().getCodeValue();
  173. String imgPrefixGFPath = "流出/".concat(videoInfo.getMainWho()).concat("/").concat(videoInfo.getIdentificationCode()).concat("/img_gf/");
  174. String imgPrefixSYPath = "流出/".concat(videoInfo.getMainWho()).concat("/").concat(videoInfo.getIdentificationCode()).concat("/img_sy/");
  175. videoInfo.setImgPrefixGFPath(imgPrefixGFPath);
  176. videoInfo.setImgPrefixSYPath(imgPrefixSYPath);
  177. // 获取样品图像-官方
  178. File imgGFFile = new File(bubingPath, imgPrefixGFPath);
  179. if (imgGFFile.exists()) {
  180. File[] files = imgGFFile.listFiles();
  181. for (File file : files) {
  182. videoInfo.getImgGFList().add(file.getName());
  183. }
  184. videoInfo.getImgGFList().sort(Comparator.naturalOrder());
  185. }
  186. // 获取样品图像-私有
  187. File imgSYFile = new File(bubingPath, imgPrefixSYPath);
  188. if (imgSYFile.exists()) {
  189. File[] files = imgSYFile.listFiles();
  190. for (File file : files) {
  191. videoInfo.getImgSYList().add(file.getName());
  192. }
  193. videoInfo.getImgSYList().sort(Comparator.naturalOrder());
  194. }
  195. } else {
  196. videoInfo = null;
  197. }
  198. return videoInfo;
  199. }
  200. @Override
  201. public void insertOrUpdateQibing(String identificationCode, String commentfirst, String commenttwo, String commentxp, String commentscore, String javdburl) {
  202. VideoInfoOther videoInfoOther = videoInfoOtherMapper.findVideoInfoOtherByCode(identificationCode);
  203. if (videoInfoOther == null) {
  204. videoInfoOther = new VideoInfoOther();
  205. }
  206. videoInfoOther.setComment("暂无评论".equals(commenttwo) ? null : commenttwo);
  207. videoInfoOther.setCommentFirst("暂无评论".equals(commentfirst) ? null : commentfirst);
  208. videoInfoOther.setCommentXp("暂无评论".equals(commentxp) ? null : commentxp);
  209. videoInfoOther.setScore(commentscore);
  210. videoInfoOther.setXpCount(StringUtils.isEmpty(videoInfoOther.getCommentXp()) ? 0 : videoInfoOther.getCommentXp().split("\\R").length);
  211. videoInfoOther.setJavdbUrl(StringUtils.isNotEmpty(javdburl) ? javdburl : null);
  212. videoInfoOtherMapper.updateVideoInfoOther4Xp(videoInfoOther);
  213. }
  214. }