TaskRangController.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package com.yihu.jw.controller;/**
  2. * Created by nature of king on 2018/6/8.
  3. */
  4. import com.yihu.jw.entity.health.bank.TaskRangDO;
  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.TaskRangService;
  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-06-08 17:02
  21. * @desc 任务范围
  22. **/
  23. @RestController
  24. @RequestMapping(HealthBankMapping.api_health_bank_common)
  25. @Api(tags = "健康任务范围相关操作",description = "健康任务范围相关操作")
  26. public class TaskRangController extends EnvelopRestController {
  27. @Autowired
  28. private TaskRangService service;
  29. @Autowired
  30. private Tracer tracer;
  31. /**
  32. * 添加任务范围
  33. *
  34. * @param taskRang 任务范围对象
  35. * @return
  36. */
  37. @PostMapping(value = HealthBankMapping.healthBank.createTaskRang)
  38. @ApiOperation(value = "添加任务范围")
  39. public Envelop<Boolean> insert(@ApiParam(name = "taskRang",value = "任务范围JSON")
  40. @RequestParam(value = "taskRang",required = true)String taskRang){
  41. try {
  42. TaskRangDO taskRangDO = toEntity(taskRang,TaskRangDO.class);
  43. return service.insert(taskRangDO);
  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 taskRang 任务范围对象
  54. * @return
  55. */
  56. @PostMapping(value = HealthBankMapping.healthBank.updateTaskRang)
  57. @ApiOperation(value = "更新任务范围")
  58. public Envelop<Boolean> update(@ApiParam(name = "taskRang",value = "任务范围JSON")
  59. @RequestParam(value = "taskRang",required = true)String taskRang){
  60. try {
  61. TaskRangDO taskRangDO = toEntity(taskRang,TaskRangDO.class);
  62. return service.update(taskRangDO);
  63. }catch (Exception e){
  64. e.printStackTrace();
  65. tracer.getCurrentSpan().logEvent(e.getMessage());
  66. return Envelop.getError(e.getMessage());
  67. }
  68. }
  69. /**
  70. * 查看任务范围
  71. *
  72. * @param taskRang 任务范围对象
  73. * @param page 页码
  74. * @param size 分页大小
  75. * @return
  76. */
  77. @PostMapping(value = HealthBankMapping.healthBank.findTaskRang)
  78. @ApiOperation(value = "查询任务范围")
  79. public Envelop<TaskRangDO> select(@ApiParam(name = "taskRang",value = "任务范围JSON")
  80. @RequestParam(value = "taskRang",required = true)String taskRang,
  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. TaskRangDO taskRangDO = toEntity(taskRang,TaskRangDO.class);
  87. return service.selectByCondition(taskRangDO,page,size);
  88. }catch (Exception e){
  89. e.printStackTrace();
  90. tracer.getCurrentSpan().logEvent(e.getMessage());
  91. return Envelop.getError(e.getMessage());
  92. }
  93. }
  94. }