BusinessApiController.java 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package com.goafanti.customer.controller;
  2. import java.text.ParseException;
  3. import java.text.SimpleDateFormat;
  4. import java.util.Date;
  5. import javax.annotation.Resource;
  6. import org.springframework.web.bind.annotation.RequestMapping;
  7. import org.springframework.web.bind.annotation.RequestMethod;
  8. import org.springframework.web.bind.annotation.RestController;
  9. import com.goafanti.common.bo.Error;
  10. import com.goafanti.common.bo.Result;
  11. import com.goafanti.common.constant.AFTConstants;
  12. import com.goafanti.common.constant.ErrorConstants;
  13. import com.goafanti.common.controller.BaseController;
  14. import com.goafanti.common.utils.StringUtils;
  15. import com.goafanti.core.shiro.token.TokenManager;
  16. import com.goafanti.customer.bo.BusinessListBo;
  17. import com.goafanti.customer.bo.BussinessFollowBo;
  18. import com.goafanti.customer.service.BusinessService;
  19. @RestController
  20. @RequestMapping("api/admin/customer")
  21. public class BusinessApiController extends BaseController{
  22. @Resource
  23. private BusinessService businessService;
  24. /** 查询业务列表 **/
  25. @RequestMapping(value = "/listBusiness", method = RequestMethod.POST)
  26. public Result listBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  27. Result res = new Result();
  28. res.setData(businessService.listBusiness(blo, pageNo, pageSize));
  29. return res;
  30. }
  31. /** 查询业务字典 **/
  32. @RequestMapping(value = "/findBusinessGlossory",method = RequestMethod.GET)
  33. public Result findBusinessGlossory(){
  34. Result res = new Result();
  35. res.setData(businessService.findBusinessGlossory());
  36. return res;
  37. }
  38. /** 新增客户意向 **/
  39. @RequestMapping(value = "/addBusinessAndFollow", method = RequestMethod.POST)
  40. public Result addBusinessAndFollow(BussinessFollowBo bfb){
  41. Result res = new Result();
  42. if(StringUtils.isBlank(bfb.getBusinessGlossoryId()) || StringUtils.isBlank(bfb.getUid())){
  43. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  44. return res;
  45. }
  46. if(businessService.judgeBusiness(bfb.getUid(), Integer.parseInt(bfb.getBusinessGlossoryId()))>0){
  47. res.getError().add(new Error("该项业务已经被跟进"));
  48. return res;
  49. }
  50. try {
  51. businessService.addBusinessAndFollow(bfb);
  52. } catch (ParseException e) {
  53. e.printStackTrace();
  54. }
  55. return res;
  56. }
  57. /** 进入新增意向服务 **/
  58. @RequestMapping(value = "/toAddBusinessAndFollow", method = RequestMethod.GET)
  59. public Result toAddBusinessAndFollow(){
  60. Result res = new Result();
  61. BussinessFollowBo bo = new BussinessFollowBo();
  62. bo.setAdminName(TokenManager.getAdminToken().getName());
  63. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  64. bo.setCreateTime(format.format(new Date()));
  65. bo.setFollowTime(bo.getCreateTime());
  66. res.setData(bo);
  67. return res;
  68. }
  69. /** 进入修改业务意向 **/
  70. @RequestMapping(value = "/toUpdateBusiness", method = RequestMethod.GET)
  71. public Result toUpdateBusiness(String businessId){
  72. Result res = new Result();
  73. res.setData(businessService.findBusinessDetail(businessId));
  74. return res;
  75. }
  76. /** 修改业务意向 **/
  77. @RequestMapping(value = "/updateBusiness", method = RequestMethod.POST)
  78. public Result updateBusiness(BussinessFollowBo bfb){
  79. Result res = new Result();
  80. businessService.updateBusiness(bfb);
  81. return res;
  82. }
  83. }