AccountController.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. package com.yihu.jw.controller;/**
  2. * Created by nature of king on 2018/5/10.
  3. */
  4. import com.yihu.jw.entity.health.bank.AccountDO;
  5. import com.yihu.jw.entity.health.bank.CreditsDetailDO;
  6. import com.yihu.jw.restmodel.common.Envelop;
  7. import com.yihu.jw.restmodel.common.EnvelopRestController;
  8. import com.yihu.jw.rm.health.bank.HealthBankMapping;
  9. import com.yihu.jw.service.AccountService;
  10. import com.yihu.jw.service.CreditsDetailService;
  11. import io.swagger.annotations.Api;
  12. import io.swagger.annotations.ApiOperation;
  13. import io.swagger.annotations.ApiParam;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.cloud.sleuth.Tracer;
  16. import org.springframework.web.bind.annotation.PostMapping;
  17. import org.springframework.web.bind.annotation.RequestMapping;
  18. import org.springframework.web.bind.annotation.RequestParam;
  19. import org.springframework.web.bind.annotation.RestController;
  20. /**
  21. * @author wangzhinan
  22. * @create 2018-05-10 11:44
  23. * @desc account Controller
  24. **/
  25. @RestController
  26. @RequestMapping(HealthBankMapping.api_health_bank_common)
  27. @Api(tags = "银行账户相关操作",description = "银行账户相关操作")
  28. public class AccountController extends EnvelopRestController {
  29. @Autowired
  30. private AccountService service;
  31. @Autowired
  32. private CreditsDetailService creditsDetailService;
  33. @Autowired
  34. private Tracer tracer;
  35. /**
  36. * 添加账户
  37. * @param account 实体类account
  38. *
  39. * @return
  40. */
  41. @PostMapping(value = HealthBankMapping.healthBank.createAccount)
  42. @ApiOperation(value = "添加账户")
  43. public Envelop<Boolean> insert(@ApiParam(name = "account",value = "账户JSON")
  44. @RequestParam(value = "account",required = true)String account){
  45. try {
  46. AccountDO accountDO = toEntity(account,AccountDO.class);
  47. return service.insert(accountDO);
  48. }catch (Exception e){
  49. e.printStackTrace();
  50. tracer.getCurrentSpan().logEvent(e.getMessage());
  51. return Envelop.getError(e.getMessage());
  52. }
  53. }
  54. /**
  55. * 获取账户
  56. *
  57. * @param creditsDetail 积分对象
  58. * @return
  59. */
  60. @PostMapping(value = HealthBankMapping.healthBank.selectAccount)
  61. @ApiOperation(value = "获取账户信息")
  62. public Envelop<AccountDO> selectByAccount(@ApiParam(name = "creditsDetail",value = "积分JSON")
  63. @RequestParam(value = "creditsDetail",required = false)String creditsDetail){
  64. try {
  65. CreditsDetailDO creditsDetailDO = toEntity(creditsDetail,CreditsDetailDO.class);
  66. return creditsDetailService.findByTradeDirection(creditsDetailDO);
  67. }catch (Exception e){
  68. e.printStackTrace();
  69. tracer.getCurrentSpan().logEvent(e.getMessage());
  70. return Envelop.getError(e.getMessage());
  71. }
  72. }
  73. /**
  74. * 获取银行账户
  75. *
  76. * @param account 银行账户对象
  77. * @param page 页码
  78. * @param size 分页大小
  79. * @return
  80. */
  81. @PostMapping(value = HealthBankMapping.healthBank.findAccount)
  82. @ApiOperation(value = "获取银行账户信息")
  83. public Envelop<AccountDO> select(@ApiParam(name = "account",value = "账户JSON")
  84. @RequestParam(value = "account",required = false)String account,
  85. @ApiParam(name = "page", value = "第几页,从1开始")
  86. @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
  87. @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
  88. @RequestParam(value = "size", required = false)Integer size){
  89. try{
  90. AccountDO accountDO = toEntity(account,AccountDO.class);
  91. return service.findByCondition(accountDO,page,size);
  92. }catch (Exception e){
  93. e.printStackTrace();
  94. tracer.getCurrentSpan().logEvent(e.getMessage());
  95. return Envelop.getError(e.getMessage());
  96. }
  97. }
  98. /**
  99. * 查看银行账户信息
  100. *
  101. * @param account 账户信息对象
  102. * @param page 页码
  103. * @param size 每页大小
  104. * @return
  105. */
  106. /* @PostMapping(value = HealthBankMapping.healthBank.findAccount)
  107. @ApiOperation(value = "查看账户信息")
  108. public Envelop<AccountDO> getAccount(@ApiParam(name = "account",value = "账户JSON")
  109. @RequestParam(value = "account",required = false)String account,
  110. @ApiParam(name = "page", value = "第几页,从1开始")
  111. @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
  112. @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
  113. @RequestParam(value = "size", required = false)Integer size){
  114. try{
  115. AccountDO accountDO = toEntity(account,AccountDO.class);
  116. return service.findByCondition(accountDO,page,size);
  117. }catch (Exception e){
  118. e.printStackTrace();
  119. tracer.getCurrentSpan().logEvent(e.getMessage());
  120. return Envelop.getError(e.getMessage());
  121. }
  122. }*/
  123. }