InvChannelAccountController.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package com.ydtech.modules.inv.controller;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.ydtech.core.page.HttpResult;
  4. import com.ydtech.modules.base.controller.BaseController;
  5. import com.ydtech.modules.inv.model.po.InvChannelAccount;
  6. import com.ydtech.modules.inv.model.po.QueryInvChannelAccount;
  7. import com.ydtech.modules.inv.service.InvChannelAccountService;
  8. import com.ydtech.modules.order.entity.BasePageResult;
  9. import io.swagger.annotations.Api;
  10. import io.swagger.annotations.ApiOperation;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.web.bind.annotation.*;
  13. import java.time.LocalDateTime;
  14. /**
  15. *
  16. * @author jianlong
  17. * @date 2024-01-05 09:31
  18. */
  19. @Api(tags = "应收应付 - 渠道账号管理", value = "渠道账号管理")
  20. @RequestMapping("/InvChannelAccount")
  21. @RestController
  22. public class InvChannelAccountController extends BaseController {
  23. @Autowired
  24. private InvChannelAccountService invChannelAccountService;
  25. @ApiOperation("获取渠道列表")
  26. @PostMapping("getAccount")
  27. public HttpResult<BasePageResult<InvChannelAccount>> getInsAccountList(@RequestBody QueryInvChannelAccount queryInvChannelAccount){
  28. IPage<InvChannelAccount> invChannelAccountIPage = invChannelAccountService.selectAccountsList(queryInvChannelAccount);
  29. BasePageResult<InvChannelAccount> invChannelAccountBasePageResult = new BasePageResult<>(invChannelAccountIPage.getCurrent(), invChannelAccountIPage.getSize(), invChannelAccountIPage.getTotal(), invChannelAccountIPage.getPages(),
  30. invChannelAccountIPage.getRecords());
  31. return HttpResult.ok(invChannelAccountBasePageResult);
  32. }
  33. @ApiOperation("获取账户详细信息")
  34. @GetMapping("getAccountById")
  35. public HttpResult<InvChannelAccount> getInsAccountById(@RequestParam("accountId") String accountId){
  36. return HttpResult.ok("", invChannelAccountService.getById(accountId));
  37. }
  38. @ApiOperation("删除账户(只传一个id就行)")
  39. @DeleteMapping("{accountId}")
  40. public HttpResult deleteInsAccount(@PathVariable("accountId") String accountId){
  41. if (accountId!= null){
  42. InvChannelAccount invChannelAccount = invChannelAccountService.getById(accountId);
  43. if (invChannelAccountService.removeById(invChannelAccount.getId())){
  44. return HttpResult.ok("删除成功");
  45. }else {
  46. return HttpResult.error();
  47. }
  48. }else {
  49. return HttpResult.error("id不能为空");
  50. }
  51. }
  52. @ApiOperation("插入账户信息")
  53. @PostMapping("insertAccount")
  54. public HttpResult insertInsAccount(@RequestBody InvChannelAccount invChannelAccount){
  55. invChannelAccount.setCreateTime(LocalDateTime.now());
  56. invChannelAccount.setCreateName(getUserName());
  57. if (invChannelAccountService.save(invChannelAccount)){
  58. return HttpResult.ok();
  59. }else {
  60. return HttpResult.error();
  61. }
  62. }
  63. @ApiOperation("修改账户信息")
  64. @PostMapping("updateAccount")
  65. public HttpResult updateInsAccount(@RequestBody InvChannelAccount invChannelAccount){
  66. if (invChannelAccountService.saveOrUpdate(invChannelAccount)){
  67. return HttpResult.ok();
  68. }else {
  69. return HttpResult.error();
  70. }
  71. }
  72. }