CustomerManageController.java 4.3 KB

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