InvAccountController.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. @PostMapping("excel")
  28. @ApiOperation("导出账户信息")
  29. public HttpResult selectAccountExcel(@RequestBody InvAccountQueryVo invAccountQueryVo) {
  30. return invAccountService.selectAccountExcel(invAccountQueryVo);
  31. }
  32. @ApiOperation("获取账户列表")
  33. @PostMapping("getAccount")
  34. public HttpResult<IPage<InvAccount>> getInsAccountList(@RequestBody InvAccountQueryVo invAccountQueryVo) {
  35. return HttpResult.ok("", invAccountService.selectAccountsListPage(invAccountQueryVo));
  36. }
  37. @ApiOperation("查询账户卡列表")
  38. @PostMapping("getAccountCardList")
  39. public HttpResult getInsAccountCardList(@RequestBody InvAccountCard invAccountCard) {
  40. LambdaQueryWrapper<InvAccountCard> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
  41. objectLambdaQueryWrapper.eq(InvAccountCard::getAccountId, invAccountCard.getAccountId());
  42. if (invAccountCard.getBankCardNum() != null) {
  43. objectLambdaQueryWrapper.eq(InvAccountCard::getBankCardNum, invAccountCard.getBankCardNum());
  44. } else if (invAccountCard.getBank() != null) {
  45. objectLambdaQueryWrapper.eq(InvAccountCard::getBank, invAccountCard.getBank());
  46. }
  47. return HttpResult.ok("", invAccountCardService.list(objectLambdaQueryWrapper));
  48. }
  49. @ApiOperation("删除账户(只传一个id就行)")
  50. @DeleteMapping("{accountId}")
  51. public HttpResult deleteInsAccount(@PathVariable("accountId") String accountId) {
  52. if (accountId != null) {
  53. InvAccount invAccount = invAccountService.getById(accountId);
  54. invAccount.setDelFlag("1");
  55. if (invAccountService.updateById(invAccount)) {
  56. return HttpResult.ok("删除成功");
  57. } else {
  58. return HttpResult.error();
  59. }
  60. } else {
  61. return HttpResult.error("id不能为空");
  62. }
  63. }
  64. @ApiOperation("删除账户卡")
  65. @DeleteMapping("card/{bankCardNum}")
  66. public HttpResult deleteInsAccountCard(@PathVariable("bankCardNum") String bankCardNum) {
  67. if (bankCardNum == null) {
  68. throw new RuntimeException("卡号为空");
  69. }
  70. if (invAccountCardService.removeById(bankCardNum)){
  71. return HttpResult.ok("删除成功");
  72. }else {
  73. return HttpResult.error("删除失败");
  74. }
  75. }
  76. @ApiOperation("插入账户信息")
  77. @PostMapping("insertAccount")
  78. public HttpResult insertInsAccount(@RequestBody InvAccount invAccount) {
  79. if (invAccountService.save(invAccount)) {
  80. return HttpResult.ok();
  81. } else {
  82. return HttpResult.error();
  83. }
  84. }
  85. @ApiOperation("插入账户卡信息")
  86. @PostMapping("insertAccountCard")
  87. public HttpResult insertInsAccountCard(@RequestBody InvAccountCard invAccountCard) {
  88. if (invAccountCard.getAccountId() == null) {
  89. throw new RuntimeException("账户id为空");
  90. }
  91. if (invAccountCardService.insertInsAccountCard(invAccountCard) > 0) {
  92. return HttpResult.ok();
  93. } else {
  94. return HttpResult.error();
  95. }
  96. }
  97. @ApiOperation("修改账户信息")
  98. @PostMapping("updateAccount")
  99. public HttpResult updateInsAccount(@RequestBody InvAccount invAccount) {
  100. if (invAccountService.updateById(invAccount)) {
  101. return HttpResult.ok();
  102. } else {
  103. return HttpResult.error();
  104. }
  105. }
  106. @ApiOperation("修改账户卡信息")
  107. @PostMapping("updateAccountCard")
  108. public HttpResult updateInsAccountCard(@RequestBody InvAccountCard invAccountCard) {
  109. if (invAccountCard.getBankCardNum() == null) {
  110. throw new RuntimeException("卡号不能为空");
  111. }
  112. if (invAccountCardService.updateInsAccountCard(invAccountCard) > 0) {
  113. return HttpResult.ok();
  114. } else {
  115. return HttpResult.error();
  116. }
  117. }
  118. @ApiOperation("根据户名分类")
  119. @GetMapping("getAccountByAccountName")
  120. public HttpResult selectByAccountName() {
  121. return invAccountService.selectByAccountName();
  122. }
  123. }