eebb8c2156db185d226fb78ec986e816f7f512db.svn-base 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package cn.com.goldenwater.dcproj.controller.rsvr;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.model.BisInspPresSafe;
  5. import cn.com.goldenwater.dcproj.param.BisInspPresSafeParam;
  6. import cn.com.goldenwater.dcproj.service.BisInspPresSafeService;
  7. import cn.com.goldenwater.dcproj.service.BisInspRsvrRgstrService;
  8. import cn.com.goldenwater.id.util.UuidUtil;
  9. import cn.com.goldenwater.target.CheckException;
  10. import io.swagger.annotations.Api;
  11. import io.swagger.annotations.ApiOperation;
  12. import io.swagger.annotations.ApiParam;
  13. import org.apache.commons.lang3.StringUtils;
  14. import org.slf4j.Logger;
  15. import org.slf4j.LoggerFactory;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.web.bind.annotation.*;
  18. import java.util.Date;
  19. import java.util.List;
  20. /**
  21. * @author lhc
  22. * @date 2021-3-13
  23. */
  24. @Api(value = "xxx管理", tags = "xxx管理")
  25. @RestController
  26. @RequestMapping("/bis/insp/presSafe")
  27. public class BisInspPresSafeController extends BaseController {
  28. private Logger logger = LoggerFactory.getLogger(getClass());
  29. @Autowired
  30. private BisInspPresSafeService bisInspPresSafeService;
  31. @Autowired
  32. private BisInspRsvrRgstrService bisInspRsvrRgstrService;
  33. @ApiOperation(value = "修改xxx")
  34. @RequestMapping(value = "", method = RequestMethod.POST)
  35. public BaseResponse<BisInspPresSafe> insert(@ApiParam(name = "bisInspPresSafe", value = "BisInspPresSafe", required = true)
  36. @RequestBody BisInspPresSafe bisInspPresSafe) {
  37. if (StringUtils.isBlank(bisInspPresSafe.getRgstrId())) {
  38. throw new CheckException("缺少登记表编码!");
  39. }
  40. BisInspPresSafeParam benefitsParam = new BisInspPresSafeParam();
  41. benefitsParam.setRgstrId(bisInspPresSafe.getRgstrId());
  42. List<BisInspPresSafe> list = bisInspPresSafeService.findList(benefitsParam);
  43. bisInspPresSafe.setUpTm(new Date());
  44. if (list != null && list.size() > 0) {
  45. bisInspPresSafe.setId(list.get(0).getId());
  46. bisInspPresSafeService.update(bisInspPresSafe);
  47. } else {
  48. bisInspPresSafe.setId(UuidUtil.uuid());
  49. bisInspPresSafe.setInTm(new Date());
  50. bisInspPresSafeService.insert(bisInspPresSafe);
  51. }
  52. bisInspRsvrRgstrService.updateRsvr(bisInspPresSafe.getRgstrId(), bisInspPresSafe.getStatus(), "persSafe");
  53. return buildSuccessResponse(bisInspPresSafe);
  54. }
  55. @ApiOperation(value = "根据ID删除xxx")
  56. @RequestMapping(value = "delete/{id}", method = RequestMethod.POST)
  57. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  58. int ret = bisInspPresSafeService.delete(id);
  59. return buildSuccessResponse();
  60. }
  61. @ApiOperation(value = "根据ID获取xxx(单表)")
  62. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  63. public BaseResponse<BisInspPresSafe> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  64. BisInspPresSafe bisInspPresSafe = bisInspPresSafeService.get(id);
  65. // bisInspPresSafe = Optional.ofNullable(bisInspPresSafe).orElseGet(() -> {
  66. // BisInspPresSafe presSafe = Builder.of(BisInspPresSafe::new).with(BisInspPresSafe::setRgstrId, id).build();
  67. // bisInspPresSafeService.insert(presSafe);
  68. // return presSafe;
  69. // });
  70. return buildSuccessResponse(bisInspPresSafe);
  71. }
  72. }