IntegralRuleController.java 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. package com.yijia.integral.controller;
  2. import java.util.List;
  3. import com.yijia.common.core.domain.entity.SysDept;
  4. import com.yijia.common.core.domain.model.LoginUser;
  5. import com.yijia.common.utils.SecurityUtils;
  6. import com.yijia.system.service.ISysDeptService;
  7. import org.springframework.security.access.prepost.PreAuthorize;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.PutMapping;
  12. import org.springframework.web.bind.annotation.DeleteMapping;
  13. import org.springframework.web.bind.annotation.PathVariable;
  14. import org.springframework.web.bind.annotation.RequestBody;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RestController;
  17. import com.yijia.common.annotation.Log;
  18. import com.yijia.common.core.controller.BaseController;
  19. import com.yijia.common.core.domain.AjaxResult;
  20. import com.yijia.common.enums.BusinessType;
  21. import com.yijia.integral.domain.IntegralRule;
  22. import com.yijia.integral.service.IIntegralRuleService;
  23. import com.yijia.common.utils.poi.ExcelUtil;
  24. import com.yijia.common.core.page.TableDataInfo;
  25. /**
  26. * 积分规则Controller
  27. *
  28. * @author yijia
  29. * @date 2021-02-24
  30. */
  31. @RestController
  32. @RequestMapping("/integral/rule")
  33. public class IntegralRuleController extends BaseController
  34. {
  35. @Autowired
  36. private IIntegralRuleService integralRuleService;
  37. @Autowired
  38. private ISysDeptService sysDeptService;
  39. /**
  40. * 查询积分规则列表
  41. */
  42. @GetMapping("/list")
  43. public TableDataInfo list(IntegralRule integralRule)
  44. {
  45. LoginUser currentUser = SecurityUtils.getLoginUser();
  46. SysDept dept =new SysDept();
  47. dept.setDeptId(currentUser.getUser().getDeptId());
  48. List<String> list = sysDeptService.selectDeptId(dept);
  49. if(list!=null && list.size()>0){
  50. integralRule.setStationIdList(list);
  51. integralRule.setStationId(null);
  52. }
  53. startPage();
  54. List<IntegralRule> integralRuleList = integralRuleService.selectIntegralRuleList(integralRule);
  55. return getDataTable(integralRuleList);
  56. }
  57. /**
  58. * 查询积分规则明细
  59. * @param integralRule
  60. * @return
  61. */
  62. @GetMapping("/listRuleInfo")
  63. public TableDataInfo listRuleInfo(IntegralRule integralRule)
  64. {
  65. LoginUser currentUser = SecurityUtils.getLoginUser();
  66. SysDept dept =new SysDept();
  67. dept.setDeptId(currentUser.getUser().getDeptId());
  68. List<String> list = sysDeptService.selectDeptId(dept);
  69. if(list!=null && list.size()>0){
  70. integralRule.setStationIdList(list);
  71. integralRule.setStationId(null);
  72. }
  73. startPage();
  74. List<IntegralRule> integralRuleList = integralRuleService.listRuleInfo(integralRule);
  75. return getDataTable(integralRuleList);
  76. }
  77. @GetMapping("/listRuleOne")
  78. public AjaxResult listRuleOne(IntegralRule integralRule)
  79. {
  80. LoginUser currentUser = SecurityUtils.getLoginUser();
  81. SysDept dept =new SysDept();
  82. dept.setDeptId(currentUser.getUser().getDeptId());
  83. List<String> list = sysDeptService.selectDeptId(dept);
  84. if(list!=null && list.size()>0){
  85. integralRule.setStationIdList(list);
  86. integralRule.setStationId(null);
  87. }
  88. IntegralRule rule = integralRuleService.selectIntegralRule(integralRule);
  89. return AjaxResult.success(rule);
  90. }
  91. /**
  92. * 导出积分规则列表
  93. */
  94. @Log(title = "积分规则", businessType = BusinessType.EXPORT)
  95. @GetMapping("/export")
  96. public AjaxResult export(IntegralRule integralRule)
  97. {
  98. LoginUser currentUser = SecurityUtils.getLoginUser();
  99. SysDept dept =new SysDept();
  100. dept.setDeptId(currentUser.getUser().getDeptId());
  101. List<String> list = sysDeptService.selectDeptId(dept);
  102. if(list!=null && list.size()>0){
  103. integralRule.setStationIdList(list);
  104. integralRule.setStationId(null);
  105. }
  106. List<IntegralRule> integralRuleList = integralRuleService.selectIntegralRuleList(integralRule);
  107. ExcelUtil<IntegralRule> util = new ExcelUtil<IntegralRule>(IntegralRule.class);
  108. return util.exportExcel(integralRuleList, "rule");
  109. }
  110. /**
  111. * 获取积分规则详细信息
  112. */
  113. @GetMapping(value = "/{id}")
  114. public AjaxResult getInfo(@PathVariable("id") Long id)
  115. {
  116. return AjaxResult.success(integralRuleService.selectIntegralRuleById(id));
  117. }
  118. /**
  119. * 新增积分规则
  120. */
  121. @Log(title = "积分规则", businessType = BusinessType.INSERT)
  122. @PostMapping
  123. public AjaxResult add(@RequestBody IntegralRule integralRule)
  124. {
  125. LoginUser currentUser = SecurityUtils.getLoginUser();
  126. integralRule.setStationId(currentUser.getUser().getDeptId());
  127. integralRule.setStationName(currentUser.getUser().getDept().getDeptName());
  128. if(integralRule!=null && integralRule.getIntegralActivity()==null){
  129. integralRule.setIntegralActivity("0");
  130. }
  131. return toAjax(integralRuleService.insertIntegralRule(integralRule));
  132. }
  133. /**
  134. * 修改积分规则
  135. */
  136. @Log(title = "积分规则", businessType = BusinessType.UPDATE)
  137. @PutMapping
  138. public AjaxResult edit(@RequestBody IntegralRule integralRule)
  139. {
  140. LoginUser currentUser = SecurityUtils.getLoginUser();
  141. integralRule.setStationId(currentUser.getUser().getDeptId());
  142. integralRule.setStationName(currentUser.getUser().getDept().getDeptName());
  143. if(integralRule!=null && integralRule.getIntegralActivity()==null){
  144. integralRule.setIntegralActivity("0");
  145. }
  146. return toAjax(integralRuleService.updateIntegralRule(integralRule));
  147. }
  148. /**
  149. * 删除积分规则
  150. */
  151. @Log(title = "积分规则", businessType = BusinessType.DELETE)
  152. @DeleteMapping("/{ids}")
  153. public AjaxResult remove(@PathVariable Long[] ids)
  154. {
  155. return toAjax(integralRuleService.deleteIntegralRuleByIds(ids));
  156. }
  157. }