InvAccountController.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. package com.ydtech.modules.inv.controller;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.metadata.IPage;
  4. import com.ydtech.core.page.HttpResult;
  5. import com.ydtech.modules.inv.model.InvAccount;
  6. import com.ydtech.modules.inv.model.InvAccountCard;
  7. import com.ydtech.modules.inv.model.vo.InvAccountQueryVo;
  8. import com.ydtech.modules.inv.service.InvAccountCardService;
  9. import com.ydtech.modules.inv.service.InvAccountService;
  10. import io.swagger.annotations.Api;
  11. import io.swagger.annotations.ApiOperation;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.web.bind.annotation.*;
  14. import java.sql.Wrapper;
  15. /**
  16. * @author jianlong
  17. * @date 2024-01-05 09:31
  18. */
  19. @Api(tags = "账户管理", value = "账户管理")
  20. @RequestMapping("/invAccount")
  21. @RestController
  22. public class InvAccountController {
  23. @Autowired
  24. private InvAccountService invAccountService;
  25. @Autowired
  26. private InvAccountCardService invAccountCardService;
  27. @ApiOperation("获取账户列表")
  28. @PostMapping("getAccount")
  29. public HttpResult<IPage<InvAccount>> getInsAccountList(@RequestBody InvAccountQueryVo invAccountQueryVo) {
  30. return HttpResult.ok("", invAccountService.selectAccountsListPage(invAccountQueryVo));
  31. }
  32. @ApiOperation("查询账户卡列表")
  33. @PostMapping("getAccountCardList")
  34. public HttpResult getInsAccountCardList(@RequestBody InvAccountCard invAccountCard) {
  35. LambdaQueryWrapper<InvAccountCard> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
  36. objectLambdaQueryWrapper.eq(InvAccountCard::getAccountId, invAccountCard.getAccountId());
  37. if (invAccountCard.getBankCardNum() != null) {
  38. objectLambdaQueryWrapper.eq(InvAccountCard::getBankCardNum, invAccountCard.getBankCardNum());
  39. } else if (invAccountCard.getBank() != null) {
  40. objectLambdaQueryWrapper.eq(InvAccountCard::getBank, invAccountCard.getBank());
  41. }
  42. return HttpResult.ok("", invAccountCardService.list(objectLambdaQueryWrapper));
  43. }
  44. @ApiOperation("删除账户(只传一个id就行)")
  45. @DeleteMapping("{accountId}")
  46. public HttpResult deleteInsAccount(@PathVariable("accountId") String accountId) {
  47. if (accountId != null) {
  48. InvAccount invAccount = invAccountService.getById(accountId);
  49. invAccount.setDelFlag("1");
  50. if (invAccountService.updateById(invAccount)) {
  51. return HttpResult.ok("删除成功");
  52. } else {
  53. return HttpResult.error();
  54. }
  55. } else {
  56. return HttpResult.error("id不能为空");
  57. }
  58. }
  59. @ApiOperation("删除账户卡")
  60. @DeleteMapping("card/{bankCardNum}")
  61. public HttpResult deleteInsAccountCard(@PathVariable("bankCardNum") String bankCardNum) {
  62. if (bankCardNum == null) {
  63. throw new RuntimeException("卡号为空");
  64. }
  65. if (invAccountCardService.removeById(bankCardNum)){
  66. return HttpResult.ok("删除成功");
  67. }else {
  68. return HttpResult.error("删除失败");
  69. }
  70. }
  71. @ApiOperation("插入账户信息")
  72. @PostMapping("insertAccount")
  73. public HttpResult insertInsAccount(@RequestBody InvAccount invAccount) {
  74. if (invAccountService.save(invAccount)) {
  75. return HttpResult.ok();
  76. } else {
  77. return HttpResult.error();
  78. }
  79. }
  80. @ApiOperation("插入账户卡信息")
  81. @PostMapping("insertAccountCard")
  82. public HttpResult insertInsAccountCard(@RequestBody InvAccountCard invAccountCard) {
  83. if (invAccountCard.getAccountId() == null) {
  84. throw new RuntimeException("账户id为空");
  85. }
  86. if (invAccountCardService.insertInsAccountCard(invAccountCard) > 0) {
  87. return HttpResult.ok();
  88. } else {
  89. return HttpResult.error();
  90. }
  91. }
  92. @ApiOperation("修改账户信息")
  93. @PostMapping("updateAccount")
  94. public HttpResult updateInsAccount(@RequestBody InvAccount invAccount) {
  95. if (invAccountService.updateById(invAccount)) {
  96. return HttpResult.ok();
  97. } else {
  98. return HttpResult.error();
  99. }
  100. }
  101. @ApiOperation("修改账户卡信息")
  102. @PostMapping("updateAccountCard")
  103. public HttpResult updateInsAccountCard(@RequestBody InvAccountCard invAccountCard) {
  104. if (invAccountCard.getBankCardNum() == null) {
  105. throw new RuntimeException("卡号不能为空");
  106. }
  107. if (invAccountCardService.updateInsAccountCard(invAccountCard) > 0) {
  108. return HttpResult.ok();
  109. } else {
  110. return HttpResult.error();
  111. }
  112. }
  113. @ApiOperation("根据户名分类")
  114. @GetMapping("getAccountByAccountName")
  115. public HttpResult selectByAccountName() {
  116. return invAccountService.selectByAccountName();
  117. }
  118. }