BgController.java 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. package top.lvzhiqiang.controller;
  2. import org.springframework.stereotype.Controller;
  3. import org.springframework.ui.Model;
  4. import org.springframework.web.bind.annotation.RequestMapping;
  5. import org.springframework.web.bind.annotation.ResponseBody;
  6. import org.springframework.web.multipart.MultipartFile;
  7. import top.lvzhiqiang.dto.R;
  8. import top.lvzhiqiang.exception.ParameterException;
  9. import top.lvzhiqiang.service.BgService;
  10. import top.lvzhiqiang.util.StringUtils;
  11. import javax.annotation.Resource;
  12. import java.io.IOException;
  13. /**
  14. * BG Controller
  15. *
  16. * @author lvzhiqiang
  17. * 2022/4/16 16:10
  18. */
  19. @Controller
  20. @RequestMapping("/bg")
  21. public class BgController {
  22. @Resource
  23. private BgService bgService;
  24. /**
  25. * 初始化骑兵数据
  26. *
  27. * @author lvzhiqiang
  28. * 2022/4/16 16:10
  29. */
  30. @RequestMapping("/initQibingData")
  31. @ResponseBody
  32. public R initQibingData() {
  33. bgService.initQibingData();
  34. return R.ok();
  35. }
  36. @RequestMapping("/ftlIndex")
  37. public String ftlIndex(Model model) {
  38. return "ftlIndex";
  39. }
  40. /**
  41. * 上传识别码文件
  42. *
  43. * @author lvzhiqiang
  44. * 2022/4/16 16:10
  45. */
  46. @RequestMapping("/uploadFile4IdentificationCode")
  47. @ResponseBody
  48. public R uploadFile4IdentificationCode(MultipartFile file, Integer isDel) throws IOException {
  49. if (StringUtils.isEmpty(file.getOriginalFilename())) {
  50. throw new ParameterException("文件为空!");
  51. } else {
  52. if (!file.getOriginalFilename().toLowerCase().endsWith("txt")) {
  53. throw new ParameterException("文件格式不正确!!");
  54. }
  55. }
  56. if (null == isDel) {
  57. isDel = 2;
  58. }
  59. bgService.uploadFile4IdentificationCode(file.getInputStream(), isDel);
  60. return R.ok();
  61. }
  62. /**
  63. * 上传识别码文件
  64. *
  65. * @author lvzhiqiang
  66. * 2022/4/16 16:10
  67. */
  68. @RequestMapping("/single4IdentificationCode")
  69. @ResponseBody
  70. public R single4IdentificationCode(String identificationCode) {
  71. if (StringUtils.isEmpty(identificationCode)) {
  72. throw new ParameterException("identificationCode为空!");
  73. }
  74. bgService.single4IdentificationCode(identificationCode);
  75. return R.ok();
  76. }
  77. /**
  78. * Jsoup IcodePool
  79. *
  80. * @author lvzhiqiang
  81. * 2022/4/16 16:10
  82. */
  83. @RequestMapping("/jsoupIcodePool")
  84. @ResponseBody
  85. public R jsoupIcodePool(Integer status, Integer isDel) {
  86. if (null == status) {
  87. status = 1;
  88. }
  89. if (null == isDel) {
  90. isDel = 2;
  91. }
  92. bgService.jsoupIcodePool(status, isDel);
  93. return R.ok();
  94. }
  95. /**
  96. * findDicCode
  97. *
  98. * @author lvzhiqiang
  99. * 2022/5/3 17:37
  100. */
  101. @RequestMapping("/findDicCode")
  102. @ResponseBody
  103. public String findDicCode(String codeDesc, String order) throws IllegalAccessException {
  104. return bgService.findDicCode(codeDesc, order);
  105. }
  106. /**
  107. * findIcodePool
  108. *
  109. * @author lvzhiqiang
  110. * 2022/5/3 17:37
  111. */
  112. @RequestMapping("/findIcodePool")
  113. @ResponseBody
  114. public String findIcodePool(String identificationCode, Integer status, String order) throws IllegalAccessException {
  115. if (StringUtils.isNotEmpty(identificationCode)) {
  116. identificationCode = identificationCode.toUpperCase();
  117. }
  118. return bgService.findIcodePool(identificationCode, status, order);
  119. }
  120. /**
  121. * findVideoSitePool
  122. *
  123. * @author lvzhiqiang
  124. * 2022/5/3 17:37
  125. */
  126. @RequestMapping("/findVideoSitePool")
  127. @ResponseBody
  128. public String findVideoSitePool(String url, String order) throws IllegalAccessException {
  129. return bgService.findVideoSitePool(url, order);
  130. }
  131. /**
  132. * findVideoInfoPool
  133. *
  134. * @author lvzhiqiang
  135. * 2022/5/3 17:37
  136. */
  137. @RequestMapping("/findVideoInfoPool")
  138. @ResponseBody
  139. public String findVideoInfoPool(String identificationCode, Integer type, String order, String crudT) throws IllegalAccessException {
  140. if (StringUtils.isNotEmpty(identificationCode)) {
  141. identificationCode = identificationCode.toUpperCase();
  142. }
  143. if (StringUtils.isEmpty(crudT)) {
  144. crudT = "1";
  145. }
  146. return bgService.findVideoInfoPool(identificationCode, type, order, crudT);
  147. }
  148. /**
  149. * findVideoInfo
  150. *
  151. * @author lvzhiqiang
  152. * 2022/5/3 17:37
  153. */
  154. @RequestMapping("/findVideoInfo")
  155. @ResponseBody
  156. public String findVideoInfo(String identificationCode, Integer type, String order, String crudT) throws IllegalAccessException {
  157. if (StringUtils.isNotEmpty(identificationCode)) {
  158. identificationCode = identificationCode.toUpperCase();
  159. }
  160. if (StringUtils.isEmpty(crudT)) {
  161. crudT = "1";
  162. }
  163. return bgService.findVideoInfo(identificationCode, type, order, crudT);
  164. }
  165. /**
  166. * insetOrupdateScoreOrComment
  167. *
  168. * @author lvzhiqiang
  169. * 2022/5/4 9:54
  170. */
  171. @RequestMapping("/insertOrUpdateScoreOrComment")
  172. @ResponseBody
  173. public String insertOrUpdateScoreOrComment(String identificationCode, String score, String comment) throws IllegalAccessException {
  174. if (StringUtils.isEmpty(identificationCode)) {
  175. throw new ParameterException("identificationCode为空!");
  176. }
  177. if (StringUtils.isEmpty(score) && StringUtils.isEmpty(comment)) {
  178. throw new ParameterException("score和comment不能都为空!");
  179. }
  180. return bgService.insertOrUpdateScoreOrComment(identificationCode.toUpperCase(), score, comment);
  181. }
  182. }