ExchangeGoodsController.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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.web.MixEnvelop;
  6. import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
  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 EnvelopRestEndpoint {
  27. @Autowired
  28. private ExchangeGoodsService service;
  29. @Autowired
  30. private Tracer tracer;
  31. /**
  32. * 查看兑换的产品
  33. *
  34. * @param exchangeGoods 兑换产品json
  35. * @param page 页码
  36. * @param size 每页大小
  37. * @return
  38. */
  39. @PostMapping(value = HealthBankMapping.healthBank.findExchangeGoods)
  40. @ApiOperation(value = "查看兑换商品信息")
  41. public MixEnvelop<ExchangeGoodsDO, 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 MixEnvelop.getError(e.getMessage());
  54. }
  55. }
  56. /**
  57. *
  58. * @param exchangeGoods
  59. * @return
  60. */
  61. @PostMapping(value = HealthBankMapping.healthBank.exchangeGoods)
  62. @ApiOperation(value = "兑换奖品")
  63. public MixEnvelop<ExchangeGoodsDO, ExchangeGoodsDO> exchangeGoods(@ApiParam(name = "exchangeGoods",value = "兑换商品JSON")
  64. @RequestParam(value = "exchangeGoods",required = false)String exchangeGoods){
  65. try{
  66. ExchangeGoodsDO exchangeGoodsDO = toEntity(exchangeGoods,ExchangeGoodsDO.class);
  67. return service.insert(exchangeGoodsDO);
  68. }catch (Exception e){
  69. e.printStackTrace();
  70. tracer.getCurrentSpan().logEvent(e.getMessage());
  71. return MixEnvelop.getError(e.getMessage());
  72. }
  73. }
  74. /* *//**
  75. * exchange goods
  76. *
  77. * @param exchangeGoods
  78. * @return
  79. *//*
  80. @PostMapping(value = HealthBankMapping.healthBank.exchangeGoods)
  81. @ApiOperation(value = "兑换商品")
  82. public Envelop<Boolean> exchangeGoods(@ApiParam(name = "exchangeGoods",value = "兑换商品JSON")
  83. @RequestParam(value = "exchangeGoods")String exchangeGoods){
  84. try {
  85. ExchangeGoodsDO exchangeGoodsDO =toEntity(exchangeGoods,ExchangeGoodsDO.class);
  86. return service.insert(exchangeGoodsDO);
  87. }catch (Exception e){
  88. e.printStackTrace();
  89. tracer.getCurrentSpan().logEvent(e.getMessage());
  90. return Envelop.getError(e.getMessage());
  91. }
  92. }*/
  93. }