UserClueApiController.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package com.goafanti.customer.controller;
  2. import com.goafanti.common.bo.Result;
  3. import com.goafanti.common.controller.BaseApiController;
  4. import com.goafanti.common.utils.excel.NewExcelUtil;
  5. import com.goafanti.core.mybatis.page.Pagination;
  6. import com.goafanti.customer.bo.*;
  7. import com.goafanti.customer.service.UserClueService;
  8. import org.springframework.beans.factory.annotation.Value;
  9. import org.springframework.web.bind.annotation.*;
  10. import org.springframework.web.multipart.MultipartFile;
  11. import javax.annotation.Resource;
  12. import java.util.List;
  13. @RestController
  14. @RequestMapping("/api/admin/userClue")
  15. public class UserClueApiController extends BaseApiController{
  16. @Resource
  17. private UserClueService userClueService;
  18. @Value(value = "${upload.path}")
  19. private String uploadPath = null;
  20. /**
  21. * 客户线索列表
  22. * @param in
  23. * @return
  24. */
  25. @GetMapping("/list")
  26. public Result<Pagination<OutUserClueList>> list(InputUserClueList in) {
  27. return new Result(userClueService.list(in));
  28. }
  29. /**
  30. * 导入客户线索
  31. * @return
  32. */
  33. @PostMapping("/import")
  34. public Result importUserClue( @RequestParam(value = "file", required = false) MultipartFile file) {
  35. NewExcelUtil<OutUserClueExcel> excelUtil=new NewExcelUtil<>(OutUserClueExcel.class);
  36. List<OutUserClueExcel> list =null;
  37. try {
  38. list=excelUtil.importExcel(file.getInputStream(),1);
  39. } catch (Exception e) {
  40. throw new RuntimeException(e);
  41. }
  42. Result res = new Result();
  43. return res.data(userClueService.pushImportUserClue(list));
  44. }
  45. /**
  46. * 导出客户线索模版
  47. * @return
  48. */
  49. @GetMapping("/exportTemplate")
  50. public Result exportList() {
  51. return new Result("/tmp/userClue_template.xlsx");
  52. }
  53. /**
  54. * 新增客户线索
  55. * @return
  56. */
  57. @PostMapping("/add")
  58. public Result add( InputUserClueBo in) {
  59. Result res = new Result();
  60. return res.data(userClueService.add(in));
  61. }
  62. /**
  63. * 线索客户转移
  64. * @param in type 0=转交, 1退回线索客户,2=移除线索客户,3=领取线索客户
  65. * @return
  66. */
  67. @PostMapping("/transfer")
  68. public Result transfer( InputUserClueTransferBo in) {
  69. Result res = new Result();
  70. if (in.getType()==0&&in.getTransferId()==null){
  71. res.getError().add(buildError("转移编号不能为空"));
  72. return res;
  73. }
  74. return res.data(userClueService.updateTransfer(in));
  75. }
  76. }