package top.lvzhiqiang.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import top.lvzhiqiang.dto.R; import top.lvzhiqiang.exception.ParameterException; import top.lvzhiqiang.service.BgService; import top.lvzhiqiang.util.StringUtils; import javax.annotation.Resource; import java.io.IOException; /** * BG Controller * * @author lvzhiqiang * 2022/4/16 16:10 */ @Controller @RequestMapping("/bg") public class BgController { @Resource private BgService bgService; /** * 初始化骑兵数据 * * @author lvzhiqiang * 2022/4/16 16:10 */ @RequestMapping("/initQibingData") @ResponseBody public R initQibingData() { bgService.initQibingData(); return R.ok(); } @RequestMapping("/ftlIndex") public String ftlIndex(Model model) { return "ftlIndex"; } /** * 上传识别码文件 * * @author lvzhiqiang * 2022/4/16 16:10 */ @RequestMapping("/uploadFile4IdentificationCode") @ResponseBody public R uploadFile4IdentificationCode(MultipartFile file, Integer isDel) throws IOException { if (StringUtils.isEmpty(file.getOriginalFilename())) { throw new ParameterException("文件为空!"); } else { if (!file.getOriginalFilename().toLowerCase().endsWith("txt")) { throw new ParameterException("文件格式不正确!!"); } } if (null == isDel) { isDel = 2; } bgService.uploadFile4IdentificationCode(file.getInputStream(), isDel); return R.ok(); } /** * 上传识别码文件 * * @author lvzhiqiang * 2022/4/16 16:10 */ @RequestMapping("/single4IdentificationCode") @ResponseBody public R single4IdentificationCode(String identificationCode) { if (StringUtils.isEmpty(identificationCode)) { throw new ParameterException("identificationCode为空!"); } bgService.single4IdentificationCode(identificationCode); return R.ok(); } /** * Jsoup IcodePool * * @author lvzhiqiang * 2022/4/16 16:10 */ @RequestMapping("/jsoupIcodePool") @ResponseBody public R jsoupIcodePool(Integer status, Integer isDel) { if (null == status) { status = 1; } if (null == isDel) { isDel = 2; } bgService.jsoupIcodePool(status, isDel); return R.ok(); } /** * findDicCode * * @author lvzhiqiang * 2022/5/3 17:37 */ @RequestMapping("/findDicCode") @ResponseBody public String findDicCode(String codeDesc, String order) throws IllegalAccessException { return bgService.findDicCode(codeDesc, order); } /** * findIcodePool * * @author lvzhiqiang * 2022/5/3 17:37 */ @RequestMapping("/findIcodePool") @ResponseBody public String findIcodePool(String identificationCode, Integer status, String order) throws IllegalAccessException { if (StringUtils.isNotEmpty(identificationCode)) { identificationCode = identificationCode.toUpperCase(); } return bgService.findIcodePool(identificationCode, status, order); } /** * findVideoSitePool * * @author lvzhiqiang * 2022/5/3 17:37 */ @RequestMapping("/findVideoSitePool") @ResponseBody public String findVideoSitePool(String url, String order) throws IllegalAccessException { return bgService.findVideoSitePool(url, order); } /** * findVideoInfoPool * * @author lvzhiqiang * 2022/5/3 17:37 */ @RequestMapping("/findVideoInfoPool") @ResponseBody public String findVideoInfoPool(String identificationCode, Integer type, String order, String crudT) throws IllegalAccessException { if (StringUtils.isNotEmpty(identificationCode)) { identificationCode = identificationCode.toUpperCase(); } if (StringUtils.isEmpty(crudT)) { crudT = "1"; } return bgService.findVideoInfoPool(identificationCode, type, order, crudT); } /** * findVideoInfo * * @author lvzhiqiang * 2022/5/3 17:37 */ @RequestMapping("/findVideoInfo") @ResponseBody public String findVideoInfo(String identificationCode, Integer type, String order, String crudT) throws IllegalAccessException { if (StringUtils.isNotEmpty(identificationCode)) { identificationCode = identificationCode.toUpperCase(); } if (StringUtils.isEmpty(crudT)) { crudT = "1"; } return bgService.findVideoInfo(identificationCode, type, order, crudT); } /** * insetOrupdateScoreOrComment * * @author lvzhiqiang * 2022/5/4 9:54 */ @RequestMapping("/insertOrUpdateScoreOrComment") @ResponseBody public String insertOrUpdateScoreOrComment(String identificationCode, String score, String comment) throws IllegalAccessException { if (StringUtils.isEmpty(identificationCode)) { throw new ParameterException("identificationCode为空!"); } if (StringUtils.isEmpty(score) && StringUtils.isEmpty(comment)) { throw new ParameterException("score和comment不能都为空!"); } return bgService.insertOrUpdateScoreOrComment(identificationCode.toUpperCase(), score, comment); } }