CheckRuleController.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package com.xintong.visualinspection.controller;
  2. import java.util.List;
  3. import javax.validation.Valid;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.web.bind.annotation.RequestBody;
  6. import org.springframework.web.bind.annotation.RequestMapping;
  7. import org.springframework.web.bind.annotation.RestController;
  8. import com.mysql.jdbc.StringUtils;
  9. import com.xintong.visualinspection.bean.CheckRule;
  10. import com.xintong.visualinspection.err.BusinessException;
  11. import com.xintong.visualinspection.service.CheckRuleService;
  12. /**
  13. * 文件名:TestController
  14. * 版本信息:日期:2017/3/30 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
  15. */
  16. @RestController
  17. @RequestMapping("/checkRule")
  18. public class CheckRuleController extends BaseController {
  19. @Autowired
  20. private CheckRuleService checkRuleService;
  21. /**
  22. * 添加考核办法
  23. * @return
  24. * String
  25. * @exception
  26. * @since 1.0.0
  27. */
  28. @RequestMapping(value = "/add")
  29. public String add(@Valid @RequestBody CheckRule checkRule){
  30. checkRuleService.insert(checkRule);
  31. return super.returnSuccessResult("添加成功");
  32. }
  33. /**
  34. * 修改考核办法
  35. * @return
  36. * String
  37. * @exception
  38. * @since 1.0.0
  39. */
  40. @RequestMapping(value = "/update")
  41. public String update(@Valid @RequestBody CheckRule checkRule){
  42. if(checkRule.getId()==null){
  43. throw new BusinessException(20002);
  44. }
  45. checkRuleService.update(checkRule);
  46. return super.returnSuccessResult("修改成功");
  47. }
  48. /**
  49. * 删除考核办法
  50. * @return
  51. * String
  52. * @exception
  53. * @since 1.0.0
  54. */
  55. @RequestMapping(value = "/delete")
  56. public String delete(@RequestBody CheckRule checkRule){
  57. if(checkRule.getId()==null){
  58. throw new BusinessException(20002);
  59. }
  60. checkRuleService.delete(checkRule.getId());
  61. return super.returnSuccessResult("删除成功");
  62. }
  63. /**
  64. * 通过id获取考核办法
  65. * @return
  66. * String
  67. * @exception
  68. * @since 1.0.0
  69. */
  70. @RequestMapping(value = "/getById")
  71. public String getById(@RequestBody CheckRule checkRule){
  72. if(checkRule.getId()==null){
  73. throw new BusinessException(20002);
  74. }
  75. CheckRule cr = checkRuleService.getById(checkRule.getId());
  76. return super.returnSuccessResult(cr);
  77. }
  78. /**
  79. * 通过名称获取考核办法
  80. * @return
  81. * String
  82. * @exception
  83. * @since 1.0.0
  84. */
  85. @RequestMapping(value = "/getByName")
  86. public String getByName(@RequestBody CheckRule checkRule){
  87. if(StringUtils.isNullOrEmpty(checkRule.getName())){
  88. throw new BusinessException(21101);
  89. }
  90. List<CheckRule> crList = checkRuleService.getByName(checkRule.getName());
  91. return super.returnSuccessResult(crList);
  92. }
  93. }