KuaishouPromoterController.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. package com.ruixuan.isc.controller;
  2. import com.ruixuan.common.core.controller.BaseController;
  3. import com.ruixuan.common.core.domain.AjaxResult;
  4. import com.ruixuan.common.core.page.TableDataInfo;
  5. import com.ruixuan.isc.entity.KuaishouPromoter;
  6. import com.ruixuan.isc.service.IKuaishouPromoterService;
  7. import com.ruixuan.isc.utils.Tess4jClient;
  8. import io.swagger.annotations.Api;
  9. import io.swagger.annotations.ApiOperation;
  10. import io.swagger.annotations.ApiParam;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.web.bind.annotation.GetMapping;
  13. import org.springframework.web.bind.annotation.PostMapping;
  14. import org.springframework.web.bind.annotation.RequestBody;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RequestParam;
  17. import org.springframework.web.bind.annotation.RestController;
  18. import org.springframework.web.multipart.MultipartFile;
  19. import java.util.List;
  20. /**
  21. * 快手达人 信息Controller
  22. *
  23. * @author ruoyi
  24. * @date 2023-02-03
  25. */
  26. @Api(tags = "快手达人")
  27. @RestController
  28. @RequestMapping("/kuaishou/promoter")
  29. public class KuaishouPromoterController extends BaseController {
  30. @Autowired
  31. private IKuaishouPromoterService kuaishouPromoterService;
  32. /**
  33. * 查询快手达人 信息列表
  34. */
  35. @GetMapping("/list")
  36. @ApiOperation(value = "查询快手达人")
  37. public TableDataInfo list(@ApiParam("创建人ID") @RequestParam(value = "userId", required = true) Long userId,
  38. @ApiParam("达人ID") @RequestParam(value = "promoterId", required = false) Long promoterId,
  39. @ApiParam("达人名称") @RequestParam(value = "promoterNickName", required = false) String promoterNickName) {
  40. List<KuaishouPromoter> list = kuaishouPromoterService.selectKuaishouPromoterList(userId, promoterId, promoterNickName);
  41. return getDataTable(list);
  42. }
  43. /**
  44. * 获取快手达人 信息详细信息
  45. */
  46. @GetMapping(value = "/getById")
  47. @ApiOperation(value = "获取快手达人信息详细信息")
  48. public AjaxResult getById(@ApiParam("主键") @RequestParam(value = "id", required = true) Long id) {
  49. return AjaxResult.success(kuaishouPromoterService.selectKuaishouPromoterById(id));
  50. }
  51. /**
  52. * 获取快手达人信息
  53. */
  54. @GetMapping(value = "/getPromoterInfo")
  55. @ApiOperation(value = "获取快手达人短视频信息")
  56. public AjaxResult getPromoterInfo(@ApiParam("达人ID") @RequestParam(value = "promoterId", required = true) Long promoterId) {
  57. return kuaishouPromoterService.getPromoterInfo(promoterId);
  58. }
  59. /**
  60. * 获取快手达人信息
  61. */
  62. @GetMapping(value = "/getOnlyPromoterInfo")
  63. @ApiOperation(value = "只获取达人信息")
  64. public AjaxResult getOnlyPromoterInfo(@ApiParam("达人ID") @RequestParam(value = "promoterId", required = true) Long promoterId) {
  65. return AjaxResult.success(kuaishouPromoterService.getOnlyPromoterInfo(promoterId));
  66. }
  67. /**
  68. * 新增快手达人 信息
  69. */
  70. @PostMapping(value = "/add")
  71. @ApiOperation(value = "新增快手达人")
  72. public AjaxResult add(@RequestBody KuaishouPromoter kuaishouPromoter) {
  73. return toAjax2(kuaishouPromoterService.insertKuaishouPromoter(kuaishouPromoter));
  74. }
  75. /**
  76. * 修改快手达人 信息
  77. */
  78. @PostMapping(value = "/edit")
  79. @ApiOperation(value = "修改快手达人")
  80. public AjaxResult edit(@RequestBody KuaishouPromoter kuaishouPromoter) {
  81. return toAjax(kuaishouPromoterService.updateKuaishouPromoter(kuaishouPromoter));
  82. }
  83. /**
  84. * 删除快手达人 信息
  85. */
  86. @GetMapping("/deleteById")
  87. @ApiOperation(value = "删除快手达人")
  88. public AjaxResult deleteById(@ApiParam("主键") @RequestParam(value = "id", required = true) Long id,
  89. @ApiParam("操作人ID") @RequestParam(value = "userId", required = true) Long userId
  90. ) {
  91. return toAjax(kuaishouPromoterService.deleteKuaishouPromoterById(id, userId));
  92. }
  93. /**
  94. * 读取图片文字信息
  95. */
  96. @PostMapping(value = "/readImage")
  97. @ApiOperation(value = "读取图片文字信息")
  98. public String readImage(@RequestParam("file") MultipartFile file) {
  99. try {
  100. Tess4jClient t = new Tess4jClient();
  101. // ITesseract tesseract = new Tesseract();
  102. // File savefile = new File("C:\\Users\\Administrator\\Desktop\\test005.png");
  103. // //设置中文字体库路径
  104. // tesseract.setDatapath("D:\\download\\tessdata");
  105. // //中文识别
  106. // tesseract.setLanguage("chi_sim");
  107. // //执行ocr识别
  108. // String result = tesseract.doOCR(savefile);
  109. String result = t.getWords(file);
  110. System.out.println(result);
  111. return result;
  112. } catch (Exception e) {
  113. e.printStackTrace();
  114. }
  115. return "";
  116. }
  117. }