5e38181369553ee1874f954b278ccb389aaa3001.svn-base 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package cn.com.goldenwater.dcproj.controller.ducha;
  2. import cn.com.goldenwater.dcproj.model.AttGnrlSectBase;
  3. import cn.com.goldenwater.dcproj.param.AttGnrlSectBaseParam;
  4. import cn.com.goldenwater.dcproj.service.AttGnrlSectBaseService;
  5. import cn.com.goldenwater.core.web.BaseController;
  6. import cn.com.goldenwater.core.web.BaseResponse;
  7. import cn.com.goldenwater.dcproj.utils.StringUtils;
  8. import cn.com.goldenwater.id.util.UuidUtil;
  9. import io.swagger.annotations.Api;
  10. import io.swagger.annotations.ApiOperation;
  11. import io.swagger.annotations.ApiParam;
  12. import org.slf4j.Logger;
  13. import org.slf4j.LoggerFactory;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.util.Assert;
  16. import org.springframework.util.CollectionUtils;
  17. import org.springframework.web.bind.annotation.PathVariable;
  18. import org.springframework.web.bind.annotation.RequestBody;
  19. import org.springframework.web.bind.annotation.RequestMapping;
  20. import org.springframework.web.bind.annotation.RequestMethod;
  21. import org.springframework.web.bind.annotation.RequestParam;
  22. import org.springframework.web.bind.annotation.RestController;
  23. import java.util.List;
  24. /**
  25. * @author lhc
  26. * @date 2023-3-15
  27. */
  28. @Api(value = "通用督查对象关联标段单位信息管理",tags="通用督查对象关联标段单位信息管理")
  29. @RestController
  30. @RequestMapping("/att/gnrl/sect/base")
  31. public class AttGnrlSectBaseController extends BaseController {
  32. private Logger logger = LoggerFactory.getLogger(getClass());
  33. @Autowired
  34. private AttGnrlSectBaseService attGnrlSectBaseService;
  35. @ApiOperation(value = "添加通用督查对象关联标段单位信息")
  36. @RequestMapping(value = "/", method = RequestMethod.POST)
  37. public BaseResponse<AttGnrlSectBase> insert(@ApiParam(name = "attGnrlSectBase", value = "AttGnrlSectBase", required = true) @RequestBody AttGnrlSectBase attGnrlSectBase) {
  38. if(StringUtils.isBlank(attGnrlSectBase.getId())) {
  39. attGnrlSectBaseService.insert(attGnrlSectBase);
  40. }
  41. else{
  42. attGnrlSectBaseService.update(attGnrlSectBase);
  43. }
  44. return buildSuccessResponse(attGnrlSectBase);
  45. }
  46. @ApiOperation(value = "添加通用督查对象关联标段单位信息")
  47. @RequestMapping(value = "/insertBatch", method = RequestMethod.POST)
  48. public BaseResponse<AttGnrlSectBase> insertBatch(@ApiParam(name = "attGnrlSectBase", value = "AttGnrlSectBase", required = true) @RequestBody List<AttGnrlSectBase> attGnrlSectBases) {
  49. if(!CollectionUtils.isEmpty(attGnrlSectBases)){
  50. attGnrlSectBases.forEach((attGnrlSectBase)->{
  51. insert(attGnrlSectBase);
  52. });
  53. }
  54. return buildSuccessResponse();
  55. }
  56. @ApiOperation(value = "根据ID删除通用督查对象关联标段单位信息")
  57. @RequestMapping(value = "delete/{id}", method = RequestMethod.POST)
  58. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  59. int ret = attGnrlSectBaseService.delete(id);
  60. return buildSuccessResponse();
  61. }
  62. @ApiOperation(value = "更新通用督查对象关联标段单位信息信息")
  63. @RequestMapping(value = "/update", method = RequestMethod.POST)
  64. public BaseResponse<AttGnrlSectBase> update(@ApiParam(name = "attGnrlSectBase", value = "AttGnrlSectBase", required = true) @RequestBody AttGnrlSectBase attGnrlSectBase) {
  65. Assert.notNull(attGnrlSectBase.getId(), "主键id为必填参数");
  66. int ret = attGnrlSectBaseService.update(attGnrlSectBase);
  67. return buildSuccessResponse(attGnrlSectBase);
  68. }
  69. @ApiOperation(value = "更新通用督查对象关联标段单位信息信息")
  70. @RequestMapping(value = "/updateBatch/{id}", method = RequestMethod.POST)
  71. public BaseResponse<AttGnrlSectBase> updateBatch(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id, @RequestBody List<AttGnrlSectBase> attGnrlSectBases) {
  72. AttGnrlSectBaseParam attGnrlSectBaseParam = new AttGnrlSectBaseParam();
  73. attGnrlSectBaseParam.setGnrlId(id);
  74. attGnrlSectBaseService.deleteBy(attGnrlSectBaseParam);
  75. if(!CollectionUtils.isEmpty(attGnrlSectBases)){
  76. attGnrlSectBases.forEach((attGnrlSectBase)->{
  77. attGnrlSectBase.setGnrlId(id);
  78. if(StringUtils.isNotBlank(attGnrlSectBase.getSectName()) && StringUtils.isNotBlank(attGnrlSectBase.getSectType())){
  79. attGnrlSectBaseService.insert(attGnrlSectBase);
  80. }
  81. });
  82. }
  83. return buildSuccessResponse();
  84. }
  85. @ApiOperation(value = "根据ID获取通用督查对象关联标段单位信息(单表)")
  86. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  87. public BaseResponse<AttGnrlSectBase> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  88. AttGnrlSectBase attGnrlSectBase = attGnrlSectBaseService.get(id);
  89. return buildSuccessResponse(attGnrlSectBase);
  90. }
  91. @ApiOperation(value = "根据ID获取通用督查对象关联标段单位信息(单表)")
  92. @RequestMapping(value = "getBy/{id}", method = RequestMethod.GET)
  93. public BaseResponse<List<AttGnrlSectBase>> getByGnrl(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  94. List<AttGnrlSectBase> attGnrlSectBases = attGnrlSectBaseService.getByGnrl(id);
  95. return buildSuccessResponse(attGnrlSectBases);
  96. }
  97. }