SealHandoverController.java 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * Neither the name of the dreamlu.net developer nor the names of its
  13. * contributors may be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. * Author: Chill 庄骞 (smallchill@163.com)
  16. */
  17. package org.springblade.bank.sealhandover.controller;
  18. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  19. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  20. import io.swagger.annotations.Api;
  21. import io.swagger.annotations.ApiOperation;
  22. import io.swagger.annotations.ApiParam;
  23. import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
  24. import lombok.AllArgsConstructor;
  25. import javax.validation.Valid;
  26. import org.springblade.bank.keypwd.entity.KeyPwd;
  27. import org.springblade.core.mp.support.Condition;
  28. import org.springblade.core.mp.support.Query;
  29. import org.springblade.core.secure.BladeUser;
  30. import org.springblade.core.secure.utils.AuthUtil;
  31. import org.springblade.core.tool.api.R;
  32. import org.springblade.core.tool.utils.DateUtil;
  33. import org.springblade.core.tool.utils.Func;
  34. import org.springframework.web.bind.annotation.*;
  35. import org.springframework.web.bind.annotation.RequestParam;
  36. import com.baomidou.mybatisplus.core.metadata.IPage;
  37. import org.springblade.bank.sealhandover.entity.SealHandover;
  38. import org.springblade.bank.sealhandover.vo.SealHandoverVO;
  39. import org.springblade.bank.sealhandover.wrapper.SealHandoverWrapper;
  40. import org.springblade.bank.sealhandover.service.ISealHandoverService;
  41. import org.springblade.core.boot.ctrl.BladeController;
  42. import java.util.List;
  43. /**
  44. * 業務印章交接登記表 控制器
  45. *
  46. * @author BladeX
  47. * @since 2021-08-13
  48. */
  49. @RestController
  50. @AllArgsConstructor
  51. @RequestMapping("bank/sealhandover")
  52. @Api(value = "業務印章交接登記表", tags = "業務印章交接登記表接口")
  53. public class SealHandoverController extends BladeController {
  54. private final ISealHandoverService sealHandoverService;
  55. /**
  56. * 详情
  57. */
  58. @GetMapping("/detail")
  59. @ApiOperationSupport(order = 1)
  60. @ApiOperation(value = "详情", notes = "传入sealHandover")
  61. public R<SealHandoverVO> detail(SealHandover sealHandover) {
  62. SealHandover detail = sealHandoverService.getOne(Condition.getQueryWrapper(sealHandover));
  63. return R.data(SealHandoverWrapper.build().entityVO(detail));
  64. }
  65. /**
  66. * 分页 業務印章交接登記表
  67. */
  68. @GetMapping("/list")
  69. @ApiOperationSupport(order = 2)
  70. @ApiOperation(value = "分页", notes = "传入sealHandover")
  71. public R<IPage<SealHandoverVO>> list(SealHandover sealHandover, Query query) {
  72. IPage<SealHandover> pages = sealHandoverService.page(Condition.getPage(query), Condition.getQueryWrapper(sealHandover));
  73. return R.data(SealHandoverWrapper.build().pageVO(pages));
  74. }
  75. /**
  76. * 自定义分页 業務印章交接登記表
  77. */
  78. @GetMapping("/page")
  79. @ApiOperationSupport(order = 3)
  80. @ApiOperation(value = "分页", notes = "传入sealHandover")
  81. public R<IPage<SealHandoverVO>> page(SealHandoverVO sealHandover, Query query) {
  82. IPage<SealHandoverVO> pages = sealHandoverService.selectSealHandoverPage(Condition.getPage(query), sealHandover);
  83. return R.data(pages);
  84. }
  85. /**
  86. * 新增 業務印章交接登記表
  87. */
  88. @PostMapping("/save")
  89. @ApiOperationSupport(order = 4)
  90. @ApiOperation(value = "新增", notes = "传入sealHandover")
  91. public R save(@Valid @RequestBody SealHandover sealHandover) {
  92. return R.status(sealHandoverService.save(sealHandover));
  93. }
  94. /**
  95. * 修改 業務印章交接登記表
  96. */
  97. @PostMapping("/update")
  98. @ApiOperationSupport(order = 5)
  99. @ApiOperation(value = "修改", notes = "传入sealHandover")
  100. public R update(@Valid @RequestBody SealHandover sealHandover) {
  101. return R.status(sealHandoverService.updateById(sealHandover));
  102. }
  103. /**
  104. * 新增或修改 業務印章交接登記表
  105. */
  106. @PostMapping("/submit")
  107. @ApiOperationSupport(order = 6)
  108. @ApiOperation(value = "新增或修改", notes = "传入sealHandover")
  109. public R submit(@Valid @RequestBody SealHandover sealHandover) {
  110. if (sealHandover.getId() == null){
  111. BladeUser currentUser = AuthUtil.getUser();
  112. sealHandover.setFillingPerson(currentUser.getUserName());
  113. sealHandover.setFillingDate(DateUtil.now());
  114. }
  115. return R.status(sealHandoverService.saveOrUpdate(sealHandover));
  116. }
  117. /**
  118. * 删除 業務印章交接登記表
  119. */
  120. @PostMapping("/remove")
  121. @ApiOperationSupport(order = 7)
  122. @ApiOperation(value = "逻辑删除", notes = "传入ids")
  123. public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
  124. return R.status(sealHandoverService.deleteLogic(Func.toLongList(ids)));
  125. }
  126. @GetMapping("/getByNoAndType")
  127. @ApiOperationSupport(order = 8)
  128. @ApiOperation(value = "获取最新一条记录", notes = "传入category,type")
  129. public R getByNoAndType(@ApiParam(required = true) @RequestParam String sealNo, @ApiParam(required = true) @RequestParam String sealType, @ApiParam(required = true) @RequestParam String orgNo){
  130. LambdaQueryWrapper<SealHandover> eq = new QueryWrapper<>(new SealHandover()).lambda().eq(SealHandover::getSealNo, sealNo)
  131. .eq(SealHandover::getSealType, sealType).eq(SealHandover::getOrgNo, orgNo).orderByDesc(SealHandover::getFillingDate);
  132. List<SealHandover> list = sealHandoverService.list(eq);
  133. if (list != null && list.size() > 0){
  134. return R.data(list.get(0));
  135. }
  136. return R.data(null);
  137. }
  138. }