CustomerLabelController.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package com.yijia.label.controller;
  2. import java.util.List;
  3. import com.yijia.common.core.domain.model.LoginUser;
  4. import com.yijia.common.utils.SecurityUtils;
  5. import com.yijia.system.service.ISysDeptService;
  6. import org.springframework.security.access.prepost.PreAuthorize;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.web.bind.annotation.GetMapping;
  9. import org.springframework.web.bind.annotation.PostMapping;
  10. import org.springframework.web.bind.annotation.PutMapping;
  11. import org.springframework.web.bind.annotation.DeleteMapping;
  12. import org.springframework.web.bind.annotation.PathVariable;
  13. import org.springframework.web.bind.annotation.RequestBody;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import com.yijia.common.annotation.Log;
  17. import com.yijia.common.core.controller.BaseController;
  18. import com.yijia.common.core.domain.AjaxResult;
  19. import com.yijia.common.enums.BusinessType;
  20. import com.yijia.label.domain.CustomerLabel;
  21. import com.yijia.label.service.ICustomerLabelService;
  22. import com.yijia.common.utils.poi.ExcelUtil;
  23. import com.yijia.common.core.page.TableDataInfo;
  24. /**
  25. * 用户标签Controller
  26. *
  27. * @author yijia
  28. * @date 2021-06-15
  29. */
  30. @RestController
  31. @RequestMapping("/label/label")
  32. public class CustomerLabelController extends BaseController
  33. {
  34. @Autowired
  35. private ICustomerLabelService customerLabelService;
  36. @Autowired
  37. private ISysDeptService deptService;
  38. /**
  39. * 查询用户标签列表
  40. */
  41. @GetMapping("/list")
  42. public TableDataInfo list(CustomerLabel customerLabel)
  43. {
  44. startPage();
  45. List<CustomerLabel> list = customerLabelService.selectCustomerLabelList(customerLabel);
  46. return getDataTable(list);
  47. }
  48. /**
  49. * 导出用户标签列表
  50. */
  51. @Log(title = "用户标签", businessType = BusinessType.EXPORT)
  52. @GetMapping("/export")
  53. public AjaxResult export(CustomerLabel customerLabel)
  54. {
  55. List<CustomerLabel> list = customerLabelService.selectCustomerLabelList(customerLabel);
  56. ExcelUtil<CustomerLabel> util = new ExcelUtil<CustomerLabel>(CustomerLabel.class);
  57. return util.exportExcel(list, "label");
  58. }
  59. /**
  60. * 获取用户标签详细信息
  61. */
  62. @GetMapping(value = "/{id}")
  63. public AjaxResult getInfo(@PathVariable("id") Integer id)
  64. {
  65. return AjaxResult.success(customerLabelService.selectCustomerLabelById(id));
  66. }
  67. /**
  68. * 新增用户标签
  69. */
  70. @Log(title = "用户标签", businessType = BusinessType.INSERT)
  71. @PostMapping
  72. public AjaxResult add(@RequestBody CustomerLabel customerLabel)
  73. {
  74. LoginUser currentUser = SecurityUtils.getLoginUser();
  75. customerLabel.setCreateBy(currentUser.getUser().getUserId()+"");
  76. customerLabel.setDelFlag("0");
  77. return toAjax(customerLabelService.insertCustomerLabel(customerLabel));
  78. }
  79. /**
  80. * 修改用户标签
  81. */
  82. @Log(title = "用户标签", businessType = BusinessType.UPDATE)
  83. @PutMapping
  84. public AjaxResult edit(@RequestBody CustomerLabel customerLabel)
  85. {
  86. LoginUser currentUser = SecurityUtils.getLoginUser();
  87. customerLabel.setUpdateBy(currentUser.getUser().getUserId()+"");
  88. return toAjax(customerLabelService.updateCustomerLabel(customerLabel));
  89. }
  90. /**
  91. * 删除用户标签
  92. */
  93. @Log(title = "用户标签", businessType = BusinessType.DELETE)
  94. @DeleteMapping("/{ids}")
  95. public AjaxResult remove(@PathVariable Integer[] ids)
  96. {
  97. return toAjax(customerLabelService.deleteCustomerLabelByIds(ids));
  98. }
  99. }