EvaluateRuleController.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package com.ims.eval.controller;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.ims.eval.config.CustomException;
  4. import com.ims.eval.entity.dto.result.R;
  5. import com.ims.eval.entity.EvaluateRule;
  6. import com.ims.eval.service.IEvaluateRuleService;
  7. import io.swagger.annotations.ApiOperation;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.web.bind.annotation.*;
  10. import java.util.Arrays;
  11. import java.util.List;
  12. /**
  13. * <p>
  14. * 考评规则表 前端控制器
  15. * </p>
  16. *
  17. * @author wang
  18. * @since 2023-02-27
  19. */
  20. @RestController
  21. @RequestMapping("//evaluate-rule")
  22. public class EvaluateRuleController {
  23. @Autowired
  24. private IEvaluateRuleService evaluateRuleService;
  25. /**
  26. * 查询 list
  27. *
  28. * @param id 主键
  29. * @param des 描述
  30. * @param binSection 业务版块
  31. * @param binStage 业务阶段
  32. * @return
  33. */
  34. //@ImsPreAuth("eval:dataDictionary:view")
  35. @GetMapping(value = "list")
  36. public R list(@RequestParam(value = "pageNum") Integer pageNum,
  37. @RequestParam(value = "pageSize") Integer pageSize,
  38. @RequestParam(value = "id", required = false) String id,
  39. @RequestParam(value = "des", required = false) String des,
  40. @RequestParam(value = "binSection", required = false) String binSection,
  41. @RequestParam(value = "binStage", required = false) String binStage) {
  42. IPage<EvaluateRule> list = evaluateRuleService.listPage(pageNum, pageSize, id, des, binSection, binStage);
  43. return R.ok().data(list);
  44. }
  45. /**
  46. * 查询 listAll
  47. *
  48. * @param id 主键
  49. * @param des 描述
  50. * @param binSection 业务版块
  51. * @param binStage 业务阶段
  52. * @return
  53. */
  54. //@ImsPreAuth("eval:dataDictionary:view")
  55. @GetMapping(value = "listAll")
  56. public R listAll(@RequestParam(value = "id", required = false) String id,
  57. @RequestParam(value = "des", required = false) String des,
  58. @RequestParam(value = "binSection", required = false) String binSection,
  59. @RequestParam(value = "binStage", required = false) String binStage) {
  60. List<EvaluateRule> list = evaluateRuleService.listAll(id, des, binSection, binStage);
  61. return R.ok().data(list);
  62. }
  63. /**
  64. * 添加
  65. *
  66. * @param evaluateRule
  67. * @return
  68. */
  69. //@ImsPreAuth("eval:dataDictionary:edit")
  70. @PostMapping(value = "/save")
  71. @ApiOperation(value = "新增(修改)", notes = "新增(修改)")
  72. public R addAll(@RequestBody EvaluateRule evaluateRule) {
  73. try {
  74. boolean b = evaluateRuleService.saveOrUpdate(evaluateRule);
  75. if (b) {
  76. return R.ok().data(b);
  77. } else {
  78. return R.error().data("保存失败!");
  79. }
  80. } catch (CustomException e){
  81. return R.customError(e.getMessage()).data("失败!");
  82. }
  83. }
  84. /**
  85. * 批量删除
  86. *
  87. * @param ids
  88. * @return
  89. */
  90. //@ImsPreAuth("eval:dataDictionary:remove")
  91. @PostMapping(value = "/remove/{ids}")
  92. @ApiOperation(value = "删除", notes = "删除")
  93. public R deleteAll(@PathVariable("ids") String ids) {
  94. String[] strings = ids.split(",");
  95. boolean b = evaluateRuleService.removeByIds(Arrays.asList(strings));
  96. if (b) {
  97. return R.ok().data(b);
  98. } else {
  99. return R.error().data("删除失败!");
  100. }
  101. }
  102. }