CustomerManageController.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. package com.yijia.customer.controller;
  2. import com.yijia.common.core.domain.entity.SysDept;
  3. import com.yijia.common.core.domain.model.LoginUser;
  4. import com.yijia.common.utils.SecurityUtils;
  5. import com.yijia.common.utils.poi.ExcelUtil;
  6. import com.yijia.customer.domain.CustomerManage;
  7. import com.yijia.customer.service.ICustomerManageService;
  8. import com.yijia.system.service.ISysDeptService;
  9. import com.yijia.system.service.ISysUserService;
  10. import org.springframework.security.access.prepost.PreAuthorize;
  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.PutMapping;
  15. import org.springframework.web.bind.annotation.DeleteMapping;
  16. import org.springframework.web.bind.annotation.PathVariable;
  17. import org.springframework.web.bind.annotation.RequestBody;
  18. import org.springframework.web.bind.annotation.RequestMapping;
  19. import org.springframework.web.bind.annotation.RestController;
  20. import com.yijia.common.annotation.Log;
  21. import com.yijia.common.core.controller.BaseController;
  22. import com.yijia.common.core.domain.AjaxResult;
  23. import com.yijia.common.enums.BusinessType;
  24. import com.yijia.common.core.page.TableDataInfo;
  25. import java.util.Arrays;
  26. import java.util.List;
  27. /**
  28. * 客户管理Controller
  29. *
  30. * @author yijia
  31. * @date 2020-12-21
  32. */
  33. @RestController
  34. @RequestMapping("/customer/manage")
  35. public class CustomerManageController extends BaseController
  36. {
  37. @Autowired
  38. private ICustomerManageService customerManageService;
  39. @Autowired
  40. private ISysDeptService deptService;
  41. /**
  42. * 查询客户管理列表
  43. */
  44. @PreAuthorize("@ss.hasPermi('customer:manage:list')")
  45. @GetMapping("/list")
  46. public TableDataInfo list(CustomerManage customerManage)
  47. {
  48. if(customerManage!=null &&customerManage.getStationId()!=null){
  49. SysDept dept =new SysDept();
  50. dept.setDeptId(customerManage.getStationId());
  51. List<String> list = deptService.selectDeptId(dept);
  52. customerManage.setStationIdList(list);
  53. customerManage.setStationId(null);
  54. }
  55. startPage();
  56. List<CustomerManage> list = customerManageService.selectCustomerManageList(customerManage);
  57. return getDataTable(list);
  58. }
  59. /**
  60. * 导出客户管理列表
  61. */
  62. @PreAuthorize("@ss.hasPermi('customer:manage:export')")
  63. @Log(title = "客户管理", businessType = BusinessType.EXPORT)
  64. @GetMapping("/export")
  65. public AjaxResult export(CustomerManage customerManage)
  66. {
  67. if(customerManage!=null &&customerManage.getStationId()!=null){
  68. SysDept dept =new SysDept();
  69. dept.setDeptId(customerManage.getStationId());
  70. List<String> list = deptService.selectDeptId(dept);
  71. customerManage.setStationIdList(list);
  72. customerManage.setStationId(null);
  73. }
  74. List<CustomerManage> list = customerManageService.selectCustomerManageList(customerManage);
  75. ExcelUtil<CustomerManage> util = new ExcelUtil<CustomerManage>(CustomerManage.class);
  76. return util.exportExcel(list, "manage");
  77. }
  78. /**
  79. * 获取客户管理详细信息
  80. */
  81. @PreAuthorize("@ss.hasPermi('customer:manage:query')")
  82. @GetMapping(value = "/{id}")
  83. public AjaxResult getInfo(@PathVariable("id") Long id)
  84. {
  85. return AjaxResult.success(customerManageService.selectCustomerManageById(id));
  86. }
  87. /**
  88. * 新增客户管理
  89. */
  90. @PreAuthorize("@ss.hasPermi('customer:manage:add')")
  91. @Log(title = "客户管理", businessType = BusinessType.INSERT)
  92. @PostMapping
  93. public AjaxResult add(@RequestBody CustomerManage customerManage)
  94. {
  95. return toAjax(customerManageService.insertCustomerManage(customerManage));
  96. }
  97. /**
  98. * 修改客户管理
  99. */
  100. @PreAuthorize("@ss.hasPermi('customer:manage:edit')")
  101. @Log(title = "客户管理", businessType = BusinessType.UPDATE)
  102. @PutMapping
  103. public AjaxResult edit(@RequestBody CustomerManage customerManage)
  104. {
  105. return toAjax(customerManageService.updateCustomerManage(customerManage));
  106. }
  107. /**
  108. * 删除客户管理
  109. */
  110. @PreAuthorize("@ss.hasPermi('customer:manage:remove')")
  111. @Log(title = "客户管理", businessType = BusinessType.DELETE)
  112. @DeleteMapping("/{ids}")
  113. public AjaxResult remove(@PathVariable Long[] ids)
  114. {
  115. return toAjax(customerManageService.deleteCustomerManageByIds(ids));
  116. }
  117. }