TaskDetailController.java 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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.TaskPatientDetailDO;
  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.TaskDetailService;
  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.*;
  15. /**
  16. * @author wangzhinan
  17. * @create 2018-04-27 9:29
  18. * @desc health blank Controller
  19. **/
  20. @RestController
  21. @RequestMapping(HealthBankMapping.api_health_bank_common)
  22. @Api(tags = "健康任务相关操作",description = "健康银行相关操作")
  23. public class TaskDetailController extends EnvelopRestController {
  24. @Autowired
  25. private TaskDetailService service;
  26. @Autowired
  27. private Tracer tracer;
  28. /**
  29. * 居民参加活动
  30. *
  31. * @param taskDetail 任务
  32. * @return
  33. */
  34. @PostMapping(value = HealthBankMapping.healthBank.createTaskDetail)
  35. @ApiOperation(value = "居民参与活动")
  36. public Envelop<Boolean> assigningTask(@ApiParam(name = "taskDetail",value = "健康任务JSON")
  37. @RequestParam(value = "taskDetail",required = true)String taskDetail){
  38. try {
  39. TaskPatientDetailDO taskPatientDetailDO = toEntity(taskDetail,TaskPatientDetailDO.class);
  40. return service.insert(taskPatientDetailDO);
  41. }catch (Exception e){
  42. e.printStackTrace();
  43. tracer.getCurrentSpan().logEvent(e.getMessage());
  44. return Envelop.getError(e.getMessage());
  45. }
  46. }
  47. /*
  48. *//**
  49. * patient find health task
  50. *
  51. * @param patientId
  52. * @param page
  53. * @param size
  54. * @return
  55. *//*
  56. @GetMapping(value = HealthBankMapping.healthBank.findTask)
  57. @ApiOperation(value = "查看健康任务")
  58. public Envelop<TaskPatientDetailDO> getTaskByPatient(@ApiParam(name = "patientId",value = "居民Id")
  59. @RequestParam(value = "patientId",required = false)String patientId,
  60. @ApiParam(name = "doctorId",value = "家庭医生Id")
  61. @RequestParam(value = "doctorId",required = false)String doctorId,
  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. return service.findTaskByPatient(patientId,doctorId,page,size);
  68. }catch (Exception e){
  69. e.printStackTrace();
  70. tracer.getCurrentSpan().logEvent(e.getMessage());
  71. return Envelop.getError(e.getMessage());
  72. }
  73. }
  74. @PostMapping(value = HealthBankMapping.healthBank.updateTask)
  75. @ApiOperation(value = "居民执行健康任务")
  76. public Envelop<Boolean> updateTask(@ApiParam(name = "taskInfo",value = "健康任务JSON")
  77. @RequestParam(value = "taskInfo",required = true)String taskInfo){
  78. try{
  79. TaskPatientDetailDO taskDetailDO = toEntity(taskInfo,TaskPatientDetailDO.class);
  80. return service.update(taskDetailDO);
  81. }catch (Exception e){
  82. e.printStackTrace();
  83. tracer.getCurrentSpan().logEvent(e.getMessage());
  84. return Envelop.getError(e.getMessage());
  85. }
  86. }*/
  87. }