TaskController.java 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package com.yihu.jw.controller;/**
  2. * Created by nature of king on 2018/4/27.
  3. */
  4. import com.yihu.jw.entity.health.bank.TaskDO;
  5. import com.yihu.jw.restmodel.common.Envelop;
  6. import com.yihu.jw.restmodel.common.EnvelopRestController;
  7. import com.yihu.jw.rm.health.bank.HealthBankMapping;
  8. import com.yihu.jw.service.TaskService;
  9. import io.swagger.annotations.Api;
  10. import io.swagger.annotations.ApiOperation;
  11. import io.swagger.annotations.ApiParam;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.cloud.sleuth.Tracer;
  14. import org.springframework.web.bind.annotation.PostMapping;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RequestParam;
  17. import org.springframework.web.bind.annotation.RestController;
  18. /**
  19. * @author wangzhinan
  20. * @create 2018-04-27 9:29
  21. * @desc health blank Controller
  22. **/
  23. @RestController
  24. @RequestMapping(HealthBankMapping.api_health_bank_common)
  25. @Api(tags = "健康任务相关操作",description = "健康银行相关操作")
  26. public class TaskController extends EnvelopRestController {
  27. @Autowired
  28. private TaskService service;
  29. @Autowired
  30. private Tracer tracer;
  31. /**
  32. * doctor assigning task patient
  33. *
  34. * @param task
  35. * @return
  36. */
  37. @PostMapping(value = HealthBankMapping.healthBank.createTask)
  38. @ApiOperation(value = "添加任务")
  39. public Envelop<Boolean> assigningTask(@ApiParam(name = "task",value = "健康任务JSON")
  40. @RequestParam(value = "task",required = true)String task){
  41. try {
  42. TaskDO taskDO = toEntity(task,TaskDO.class);
  43. return service.insert(taskDO);
  44. }catch (Exception e){
  45. e.printStackTrace();
  46. tracer.getCurrentSpan().logEvent(e.getMessage());
  47. return Envelop.getError(e.getMessage());
  48. }
  49. }
  50. @PostMapping(value = HealthBankMapping.healthBank.findTask)
  51. @ApiOperation(value = "查询任务")
  52. public Envelop<TaskDO> assigningTask(@ApiParam(name = "task",value = "健康任务JSON")
  53. @RequestParam(value = "task",required = true)String task,
  54. @ApiParam(name = "page", value = "第几页,从1开始")
  55. @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
  56. @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
  57. @RequestParam(value = "size", required = false)Integer size){
  58. try {
  59. TaskDO taskDO = toEntity(task,TaskDO.class);
  60. return service.selectByCondition(taskDO,page,size);
  61. }catch (Exception e){
  62. e.printStackTrace();
  63. tracer.getCurrentSpan().logEvent(e.getMessage());
  64. return Envelop.getError(e.getMessage());
  65. }
  66. }
  67. /**//**
  68. * patient find health task
  69. *
  70. * @param patientId
  71. * @param page
  72. * @param size
  73. * @return
  74. *//*
  75. @GetMapping(value = HealthBankMapping.healthBank.findTask)
  76. @ApiOperation(value = "查看健康任务")
  77. public Envelop<TaskDetailDO> getTaskByPatient(@ApiParam(name = "patientId",value = "居民Id")
  78. @RequestParam(value = "patientId",required = false)String patientId,
  79. @ApiParam(name = "doctorId",value = "家庭医生Id")
  80. @RequestParam(value = "doctorId",required = false)String doctorId,
  81. @ApiParam(name = "page", value = "第几页,从1开始")
  82. @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
  83. @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
  84. @RequestParam(value = "size", required = false)Integer size){
  85. try{
  86. return service.findTaskByPatient(patientId,doctorId,page,size);
  87. }catch (Exception e){
  88. e.printStackTrace();
  89. tracer.getCurrentSpan().logEvent(e.getMessage());
  90. return Envelop.getError(e.getMessage());
  91. }
  92. }
  93. @PostMapping(value = HealthBankMapping.healthBank.updateTask)
  94. @ApiOperation(value = "居民执行健康任务")
  95. public Envelop<Boolean> updateTask(@ApiParam(name = "taskInfo",value = "健康任务JSON")
  96. @RequestParam(value = "taskInfo",required = true)String taskInfo){
  97. try{
  98. TaskDetailDO taskDetailDO = toEntity(taskInfo,TaskDetailDO.class);
  99. return service.update(taskDetailDO);
  100. }catch (Exception e){
  101. e.printStackTrace();
  102. tracer.getCurrentSpan().logEvent(e.getMessage());
  103. return Envelop.getError(e.getMessage());
  104. }
  105. }*/
  106. }