ExchangeGoodsController.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package com.yihu.jw.controller;/**
  2. * Created by nature of king on 2018/5/3.
  3. */
  4. import com.yihu.jw.entity.health.bank.ExchangeGoodsDO;
  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.ExchangeGoodsService;
  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-05-03 16:17
  21. * @desc exchange goods Controller
  22. **/
  23. @RestController
  24. @RequestMapping(HealthBankMapping.api_health_bank_common)
  25. @Api(tags = "商品兑换相关操作",description = "商品兑换相关操作")
  26. public class ExchangeGoodsController extends EnvelopRestController {
  27. @Autowired
  28. private ExchangeGoodsService service;
  29. @Autowired
  30. private Tracer tracer;
  31. /**
  32. * find exchange goods
  33. *
  34. * @param exchangeGoods
  35. * @param page
  36. * @param size
  37. * @return
  38. */
  39. @PostMapping(value = HealthBankMapping.healthBank.findExchangeGoods)
  40. @ApiOperation(value = "查看兑换商品信息")
  41. public Envelop<ExchangeGoodsDO> getExchangeGoods(@ApiParam(name = "exchangeGoods",value = "兑换商品JSON")
  42. @RequestParam(value = "exchangeGoods",required = false)String exchangeGoods,
  43. @ApiParam(name = "page", value = "第几页,从1开始")
  44. @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
  45. @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
  46. @RequestParam(value = "size", required = false)Integer size){
  47. try{
  48. ExchangeGoodsDO exchangeGoodsDO = toEntity(exchangeGoods,ExchangeGoodsDO.class);
  49. return service.findByCondition(exchangeGoodsDO,page,size);
  50. }catch (Exception e){
  51. e.printStackTrace();
  52. tracer.getCurrentSpan().logEvent(e.getMessage());
  53. return Envelop.getError(e.getMessage());
  54. }
  55. }
  56. /* *//**
  57. * exchange goods
  58. *
  59. * @param exchangeGoods
  60. * @return
  61. *//*
  62. @PostMapping(value = HealthBankMapping.healthBank.exchangeGoods)
  63. @ApiOperation(value = "兑换商品")
  64. public Envelop<Boolean> exchangeGoods(@ApiParam(name = "exchangeGoods",value = "兑换商品JSON")
  65. @RequestParam(value = "exchangeGoods")String exchangeGoods){
  66. try {
  67. ExchangeGoodsDO exchangeGoodsDO =toEntity(exchangeGoods,ExchangeGoodsDO.class);
  68. return service.insert(exchangeGoodsDO);
  69. }catch (Exception e){
  70. e.printStackTrace();
  71. tracer.getCurrentSpan().logEvent(e.getMessage());
  72. return Envelop.getError(e.getMessage());
  73. }
  74. }*/
  75. }