TaskController.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. * 指派任务
  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. /**
  51. * 查询任务
  52. *
  53. * @param task 任务对象
  54. * @param page 页码
  55. * @param size 分页大小
  56. * @return
  57. */
  58. @PostMapping(value = HealthBankMapping.healthBank.findTask)
  59. @ApiOperation(value = "查询任务")
  60. public Envelop<TaskDO> assigningTask(@ApiParam(name = "task",value = "健康任务JSON")
  61. @RequestParam(value = "task",required = true)String task,
  62. @ApiParam(name = "page", value = "第几页,从1开始")
  63. @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
  64. @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
  65. @RequestParam(value = "size", required = false)Integer size){
  66. try {
  67. TaskDO taskDO = toEntity(task,TaskDO.class);
  68. return service.selectByCondition(taskDO,page,size);
  69. }catch (Exception e){
  70. e.printStackTrace();
  71. tracer.getCurrentSpan().logEvent(e.getMessage());
  72. return Envelop.getError(e.getMessage());
  73. }
  74. }
  75. /**//**
  76. * patient find health task
  77. *
  78. * @param patientId
  79. * @param page
  80. * @param size
  81. * @return
  82. *//*
  83. @GetMapping(value = HealthBankMapping.healthBank.findTask)
  84. @ApiOperation(value = "查看健康任务")
  85. public Envelop<TaskDetailDO> getTaskByPatient(@ApiParam(name = "patientId",value = "居民Id")
  86. @RequestParam(value = "patientId",required = false)String patientId,
  87. @ApiParam(name = "doctorId",value = "家庭医生Id")
  88. @RequestParam(value = "doctorId",required = false)String doctorId,
  89. @ApiParam(name = "page", value = "第几页,从1开始")
  90. @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
  91. @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
  92. @RequestParam(value = "size", required = false)Integer size){
  93. try{
  94. return service.findTaskByPatient(patientId,doctorId,page,size);
  95. }catch (Exception e){
  96. e.printStackTrace();
  97. tracer.getCurrentSpan().logEvent(e.getMessage());
  98. return Envelop.getError(e.getMessage());
  99. }
  100. }
  101. @PostMapping(value = HealthBankMapping.healthBank.updateTask)
  102. @ApiOperation(value = "居民执行健康任务")
  103. public Envelop<Boolean> updateTask(@ApiParam(name = "taskInfo",value = "健康任务JSON")
  104. @RequestParam(value = "taskInfo",required = true)String taskInfo){
  105. try{
  106. TaskDetailDO taskDetailDO = toEntity(taskInfo,TaskDetailDO.class);
  107. return service.update(taskDetailDO);
  108. }catch (Exception e){
  109. e.printStackTrace();
  110. tracer.getCurrentSpan().logEvent(e.getMessage());
  111. return Envelop.getError(e.getMessage());
  112. }
  113. }*/
  114. }