AccountController.java 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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
  38. * @return
  39. */
  40. @PostMapping(value = HealthBankMapping.healthBank.createAccount)
  41. @ApiOperation(value = "添加账户")
  42. public Envelop<Boolean> insert(@ApiParam(name = "account",value = "账户JSON")
  43. @RequestParam(value = "account",required = true)String account){
  44. try {
  45. AccountDO accountDO = toEntity(account,AccountDO.class);
  46. return service.insert(accountDO);
  47. }catch (Exception e){
  48. e.printStackTrace();
  49. tracer.getCurrentSpan().logEvent(e.getMessage());
  50. return Envelop.getError(e.getMessage());
  51. }
  52. }
  53. /**
  54. * 获取账户
  55. *
  56. * @param creditsDetail
  57. * @return
  58. */
  59. @PostMapping(value = HealthBankMapping.healthBank.selectAccount)
  60. @ApiOperation(value = "获取账户信息")
  61. public Envelop<AccountDO> selectByAccount(@ApiParam(name = "creditsDetail",value = "积分JSON")
  62. @RequestParam(value = "creditsDetail",required = false)String creditsDetail){
  63. try {
  64. CreditsDetailDO creditsDetailDO = toEntity(creditsDetail,CreditsDetailDO.class);
  65. return creditsDetailService.findByTradeDirection(creditsDetailDO);
  66. }catch (Exception e){
  67. e.printStackTrace();
  68. tracer.getCurrentSpan().logEvent(e.getMessage());
  69. return Envelop.getError(e.getMessage());
  70. }
  71. }
  72. }