CheckItemController.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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.xintong.system.err.BusinessException;
  9. import com.xintong.visualinspection.bean.CheckItem;
  10. import com.xintong.visualinspection.service.CheckItemService;
  11. /**
  12. * 文件名:CheckItemController
  13. * 版本信息:日期:2017/3/30 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
  14. */
  15. @RestController
  16. @RequestMapping("/checkItem")
  17. public class CheckItemController extends BaseController {
  18. @Autowired
  19. private CheckItemService checkItemService;
  20. /**
  21. * 添加考核项
  22. * @return
  23. * String
  24. * @exception
  25. * @since 1.0.0
  26. */
  27. @RequestMapping(value = "/add")
  28. public String add(@Valid @RequestBody CheckItem checkItem){
  29. checkItemService.insert(checkItem);
  30. return super.returnSuccessResult("添加成功");
  31. }
  32. /**
  33. * 修改考核项
  34. * @return
  35. * String
  36. * @exception
  37. * @since 1.0.0
  38. */
  39. @RequestMapping(value = "/update")
  40. public String update(@Valid @RequestBody CheckItem checkItem){
  41. checkItemService.update(checkItem);
  42. return super.returnSuccessResult("修改成功");
  43. }
  44. /**
  45. * 删除考核项
  46. * @return
  47. * String
  48. * @exception
  49. * @since 1.0.0
  50. */
  51. @RequestMapping(value = "/delete")
  52. public String delete(@RequestBody CheckItem checkItem){
  53. checkItemService.delete(checkItem.getId());
  54. return super.returnSuccessResult("删除成功");
  55. }
  56. /**
  57. * 根据id获取考核项数据
  58. * @param checkItem
  59. * @return
  60. */
  61. @RequestMapping(value = "/getById")
  62. public String getById(@RequestBody CheckItem checkItem){
  63. if(checkItem.getId()==null){
  64. throw new BusinessException(20101);
  65. }
  66. CheckItem checkItemOne = checkItemService.getById(checkItem.getId()) ;
  67. return super.returnSuccessResult(checkItemOne);
  68. }
  69. @RequestMapping(value = "/getAll")
  70. public String getAll(){
  71. List<CheckItem> checkItems = checkItemService.getAll() ;
  72. return super.returnSuccessResult(checkItems);
  73. }
  74. @RequestMapping(value = "/getForTaskById")
  75. public String getForTaskById(@RequestBody CheckItem checkItem){
  76. List<CheckItem> checkItems = checkItemService.getAll();
  77. return super.returnSuccessResult(checkItems);
  78. }
  79. /**
  80. * 通过父亲id获取考核项
  81. * @return
  82. * String
  83. * @exception
  84. * @since 1.0.0
  85. */
  86. @RequestMapping(value = "/getByParentId")
  87. public String getByParentId(@RequestBody CheckItem checkItem){
  88. if(checkItem.getParent_id()==null){
  89. throw new BusinessException(20101);
  90. }
  91. List<CheckItem> checkItemList = checkItemService.getByParentId(checkItem.getParent_id());
  92. return super.returnSuccessResult(checkItemList);
  93. }
  94. /**
  95. * 通过方法id获取考核项
  96. * @return
  97. * String
  98. * @exception
  99. * @since 1.0.0
  100. */
  101. @RequestMapping(value = "/getByRuleId")
  102. public String getByRuleId(@RequestBody CheckItem checkItem){
  103. if(checkItem.getRule_id()==null){
  104. throw new BusinessException(20101);
  105. }
  106. List<CheckItem> checkItemList = checkItemService.getByRuleId(checkItem.getRule_id());
  107. return super.returnSuccessResult(checkItemList);
  108. }
  109. }