VideoInfoServiceImpl.java 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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.mapper.VideoInfoInfantryMapper;
  10. import top.lvzhiqiang.mapper.VideoInfoMapper;
  11. import top.lvzhiqiang.mapper.VideoInfoPoolMapper;
  12. import top.lvzhiqiang.mapper.VideoInfoUncensoredMapper;
  13. import top.lvzhiqiang.service.VideoInfoService;
  14. import javax.annotation.Resource;
  15. import java.io.File;
  16. import java.util.List;
  17. import java.util.Map;
  18. /**
  19. * 电影信息ServiceImpl
  20. *
  21. * @author lvzhiqiang
  22. * 2022/4/4 15:28
  23. */
  24. @Service
  25. public class VideoInfoServiceImpl extends BaseServiceImpl<Object> implements VideoInfoService {
  26. @Resource
  27. private VideoInfoMapper videoInfoMapper;
  28. @Resource
  29. private VideoInfoPoolMapper videoInfoPoolMapper;
  30. @Resource
  31. private VideoInfoUncensoredMapper videoInfoUncensoredMapper;
  32. @Resource
  33. private VideoInfoInfantryMapper videoInfoInfantryMapper;
  34. @Value("${spring.profiles.active}")
  35. private String env;
  36. /**
  37. * 查询所有
  38. *
  39. * @return
  40. */
  41. @Override
  42. public List<VideoInfo> findAll() {
  43. return videoInfoMapper.findAll();
  44. }
  45. /**
  46. * 分页查询所有
  47. *
  48. * @return
  49. */
  50. @Override
  51. public PageInfo<VideoInfo> findAll(int pageNo, int pageSize) {
  52. PageHelper.startPage(pageNo, pageSize);
  53. List<VideoInfo> videoInfoList = videoInfoMapper.findAll();
  54. PageInfo<VideoInfo> videoInfoPageInfo = new PageInfo<>(videoInfoList);
  55. return videoInfoPageInfo;
  56. }
  57. @Override
  58. public PageInfo<VideoInfo> getVideoInfoPage(Map<String, Object> params) {
  59. Object bigType = params.get("bigType");
  60. List<VideoInfo> videoInfoList;
  61. // 转换成like
  62. paramsToLike(params, "keyword");
  63. // 分页
  64. paramsToPagination(params);
  65. // 排序
  66. paramsToSort(params);
  67. if ("骑兵".equals(bigType)) {
  68. videoInfoList = videoInfoMapper.getVideoInfoList(params);
  69. } else if ("步兵".equals(bigType)) {
  70. Object genres = params.get("genres");
  71. if (null == genres) {
  72. List<VideoGenres> videoGenresList = videoInfoInfantryMapper.findGenres();
  73. params.put("genres", videoGenresList.get(0).getName());
  74. }
  75. videoInfoList = videoInfoInfantryMapper.getVideoInfoInfantryList(params);
  76. } else if ("流出".equals(bigType)) {
  77. videoInfoList = videoInfoUncensoredMapper.getVideoInfoUncensoredList(params);
  78. } else if ("码池".equals(bigType)) {
  79. videoInfoList = videoInfoPoolMapper.getVideoInfoPoolList(params);
  80. } else {
  81. videoInfoList = videoInfoMapper.getVideoInfoList(params);
  82. }
  83. PageInfo<VideoInfo> videoInfoPageInfo = new PageInfo<>(videoInfoList);
  84. return videoInfoPageInfo;
  85. }
  86. /**
  87. * 影片信息详情
  88. *
  89. * @param type
  90. * @param code
  91. * @return
  92. */
  93. @Override
  94. public VideoInfo getVideoInfoDetail(String type, String code) {
  95. VideoInfo videoInfo;
  96. if ("qibing".equals(type)) {
  97. videoInfo = videoInfoMapper.getVideoInfoDetail(code);
  98. if (videoInfo == null) {
  99. return null;
  100. }
  101. String qibingPath = WebAppConfig.dicCodeList.stream().filter(x -> 1 == x.getType() && env.equals(x.getEnv()) && "apics_path".equals(x.getCodeKey())).findFirst().get().getCodeValue();
  102. String imgPrefixPath = "骑兵步兵/".concat(videoInfo.getIdentificationCode()).concat("/img_gf/");
  103. videoInfo.setImgPrefixPath(imgPrefixPath);
  104. // 获取样品图像-官方
  105. File imgGFFile = new File(qibingPath, imgPrefixPath);
  106. if (imgGFFile.exists()) {
  107. File[] files = imgGFFile.listFiles();
  108. for (File file : files) {
  109. videoInfo.getImgGFList().add(file.getName());
  110. }
  111. }
  112. // 获取样品图像-私有
  113. File imgSYFile = new File(qibingPath, "骑兵步兵/".concat(videoInfo.getIdentificationCode()).concat("/img_sy/"));
  114. if (imgSYFile.exists()) {
  115. File[] files = imgSYFile.listFiles();
  116. for (File file : files) {
  117. videoInfo.getImgSYList().add(file.getName());
  118. }
  119. }
  120. } else if ("bubing".equals(type)) {
  121. videoInfo = null;
  122. } else if ("liuchu".equals(type)) {
  123. videoInfo = null;
  124. } else {
  125. videoInfo = null;
  126. }
  127. return videoInfo;
  128. }
  129. }