RehabilitationPlanningController.java 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package com.yihu.rehabilitation.controller;
  2. import com.yihu.jw.rehabilitation.RehabilitationPlanningDO;
  3. import com.yihu.jw.rehabilitation.RehabilitationTreatmentProgramDO;
  4. import com.yihu.jw.restmodel.common.Envelop;
  5. import com.yihu.jw.restmodel.common.EnvelopRestController;
  6. import com.yihu.jw.restmodel.rehabilitation.RehabilitationPlanningVO;
  7. import com.yihu.jw.rm.rehabilitation.RehabilitationRequestMapping;
  8. import com.yihu.rehabilitation.service.RehabilitationPlanningService;
  9. import com.yihu.rehabilitation.service.RehabilitationTreatmentProgramService;
  10. import io.swagger.annotations.Api;
  11. import io.swagger.annotations.ApiOperation;
  12. import io.swagger.annotations.ApiParam;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.web.bind.annotation.*;
  15. /**
  16. * @author humingfen on 2018/5/2.
  17. */
  18. @RestController
  19. @RequestMapping(value = RehabilitationRequestMapping.Planning.planning)
  20. @Api(tags = "康复计划相关操作", description = "康复计划相关操作")
  21. public class RehabilitationPlanningController extends EnvelopRestController {
  22. @Autowired
  23. private RehabilitationPlanningService planningService;
  24. @Autowired
  25. private RehabilitationTreatmentProgramService TreatmentProgramService;
  26. @GetMapping(value = RehabilitationRequestMapping.Planning.findPlanningPage)
  27. @ApiOperation(value = "分页查找康复计划", notes = "分页查找康复计划")
  28. public Envelop<RehabilitationPlanningVO> findPlanningPage(@ApiParam(name = "patientId", value = "居民id", defaultValue = "")
  29. @RequestParam(value = "patientId", required = false) String patientId,
  30. @ApiParam(name = "programId", value = "康复计划id", defaultValue = "")
  31. @RequestParam(value = "programId", required = false) String programId,
  32. @ApiParam(name = "page", value = "第几页", defaultValue = "")
  33. @RequestParam(value = "page", required = false) Integer page,
  34. @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
  35. @RequestParam(value = "size", required = false) Integer size){
  36. try {
  37. if(page == null|| page < 0){
  38. page = 1;
  39. }
  40. if(size == null){
  41. size = 10;
  42. }
  43. return planningService.queryPlanningPage(page, size, patientId, programId);
  44. } catch (Exception e) {
  45. e.printStackTrace();
  46. return Envelop.getError(e.getMessage());
  47. }
  48. }
  49. @GetMapping(value = RehabilitationRequestMapping.Planning.api_create)
  50. @ApiOperation(value = "创建康复计划", notes = "创建康复计划")
  51. public Envelop<RehabilitationPlanningDO> createPlanning(@ApiParam(name = "jsonData", value = "基本信息Json", defaultValue = "")
  52. @RequestParam(value = "jsonData", required = false) String jsonData) {
  53. try {
  54. RehabilitationPlanningDO planningDO = toEntity(jsonData, RehabilitationPlanningDO.class);
  55. return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_create, planningService.create(planningDO));
  56. }catch (Exception e){
  57. e.printStackTrace();
  58. return Envelop.getError(e.getMessage());
  59. }
  60. }
  61. @GetMapping(value = RehabilitationRequestMapping.Planning.findPlanningById)
  62. @ApiOperation(value = "根据id查找治疗方案", notes = "根据id查找治疗方案")
  63. public Envelop<RehabilitationPlanningDO> findById(@ApiParam(name = "id", value = "id")
  64. @RequestParam(value = "id", required = true) String id) {
  65. try {
  66. RehabilitationPlanningDO planningDO = planningService.findById(id);
  67. return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_find, planningDO);
  68. } catch (Exception e) {
  69. e.printStackTrace();
  70. return Envelop.getError(e.getMessage());
  71. }
  72. }
  73. @GetMapping(value = RehabilitationRequestMapping.Planning.findTreatmentByProgramId)
  74. @ApiOperation(value = "根据programId查找治疗方案", notes = "根据programId查找治疗方案")
  75. public Envelop<RehabilitationPlanningDO> findTreatmentByProgramId(@ApiParam(name = "programId", value = "programId")
  76. @RequestParam(value = "programId", required = true) String programId) {
  77. try {
  78. RehabilitationTreatmentProgramDO treatmentProgramDO = TreatmentProgramService.findById(programId);
  79. return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_find, treatmentProgramDO);
  80. } catch (Exception e) {
  81. e.printStackTrace();
  82. return Envelop.getError(e.getMessage());
  83. }
  84. }
  85. @PostMapping(value = RehabilitationRequestMapping.Planning.api_update)
  86. @ApiOperation(value = "修改治疗方案", notes = "修改治疗方案(记得传入修改id)")
  87. public Envelop updatePlanning(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
  88. @RequestParam(value = "jsonData", required = true)String jsonData) {
  89. try {
  90. RehabilitationPlanningDO planningDO = toEntity(jsonData, RehabilitationPlanningDO.class);
  91. planningService.update(planningDO);
  92. return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_update);
  93. } catch (Exception e) {
  94. e.printStackTrace();
  95. return Envelop.getError(e.getMessage());
  96. }
  97. }
  98. @PostMapping(value = RehabilitationRequestMapping.Planning.api_delete)
  99. @ApiOperation(value = "删除治疗方案", notes = "删除治疗方案")
  100. public Envelop delPlanning(@ApiParam(name = "id", value = "id")
  101. @RequestParam(value = "id", required = true) String id) {
  102. try {
  103. planningService.delete(id);
  104. return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_delete);
  105. } catch (Exception e) {
  106. e.printStackTrace();
  107. return Envelop.getError(e.getMessage());
  108. }
  109. }
  110. }