51c3bec71ad44f78abd5bc9655d4e6bf99b7b49b.svn-base 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package cn.com.goldenwater.dcproj.controller.cdep;
  2. import cn.com.goldenwater.dcproj.model.BisInspCdepCon;
  3. import cn.com.goldenwater.dcproj.param.BisInspCdepConParam;
  4. import cn.com.goldenwater.dcproj.service.BisInspCdepConService;
  5. import cn.com.goldenwater.core.web.BaseController;
  6. import cn.com.goldenwater.core.web.BaseResponse;
  7. import io.swagger.annotations.Api;
  8. import io.swagger.annotations.ApiOperation;
  9. import io.swagger.annotations.ApiParam;
  10. import org.apache.commons.lang3.StringUtils;
  11. import org.slf4j.Logger;
  12. import org.slf4j.LoggerFactory;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.util.Assert;
  15. import org.springframework.web.bind.annotation.PathVariable;
  16. import org.springframework.web.bind.annotation.RequestBody;
  17. import org.springframework.web.bind.annotation.RequestMapping;
  18. import org.springframework.web.bind.annotation.RequestMethod;
  19. import org.springframework.web.bind.annotation.RestController;
  20. /**
  21. * @author zhangcheng
  22. * @date 2020-11-19
  23. */
  24. @Api(value = "检测能力混凝土管理",tags="检测能力混凝土管理")
  25. @RestController
  26. @RequestMapping("/bis/insp/cdep/con")
  27. public class BisInspCdepConController extends BaseController {
  28. private Logger logger = LoggerFactory.getLogger(getClass());
  29. @Autowired
  30. private BisInspCdepConService bisInspCdepConService;
  31. @ApiOperation(value = "添加或修改检测能力混凝土工程表(新疆)")
  32. @RequestMapping(value = "", method = RequestMethod.POST)
  33. public BaseResponse<BisInspCdepCon> insert(@ApiParam(name = "bisInspCdepCon", value = "BisInspCdepCon", required = true) @RequestBody BisInspCdepCon bisInspCdepCon) {
  34. if (StringUtils.isBlank(bisInspCdepCon.getRgstrId())){
  35. return buildFailResponse();
  36. }
  37. // 根据有无主键,来新增、更新信息
  38. int ret = 0;
  39. if(StringUtils.isBlank(bisInspCdepCon.getId())){
  40. BisInspCdepConParam param = new BisInspCdepConParam();
  41. param.setRgstrId(bisInspCdepCon.getRgstrId());
  42. BisInspCdepCon cap = bisInspCdepConService.getBy(param);
  43. if (null == cap){
  44. ret = bisInspCdepConService.insert(bisInspCdepCon);
  45. } else {
  46. bisInspCdepCon.setId(cap.getId());
  47. ret = bisInspCdepConService.update(bisInspCdepCon);
  48. }
  49. } else {
  50. bisInspCdepCon.setPersId(getCurrentPersId());
  51. ret = bisInspCdepConService.update(bisInspCdepCon);
  52. }
  53. return buildSuccessResponse(bisInspCdepCon);
  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 = bisInspCdepConService.delete(id);
  59. return buildSuccessResponse();
  60. }
  61. @ApiOperation(value = "更新xxx信息")
  62. @RequestMapping(value = "/update", method = RequestMethod.POST)
  63. public BaseResponse<BisInspCdepCon> update(@ApiParam(name = "bisInspCdepCon", value = "BisInspCdepCon", required = true) @RequestBody BisInspCdepCon bisInspCdepCon) {
  64. Assert.notNull(bisInspCdepCon.getId(), "主键id为必填参数");
  65. int ret = bisInspCdepConService.update(bisInspCdepCon);
  66. return buildSuccessResponse(bisInspCdepCon);
  67. }
  68. @ApiOperation(value = "根据ID获取检测能力混泥土工程表(新疆)(单表)")
  69. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  70. public BaseResponse<BisInspCdepCon> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  71. BisInspCdepCon bisInspCdepCon = bisInspCdepConService.get(id);
  72. if (null == bisInspCdepCon){
  73. bisInspCdepCon = new BisInspCdepCon();
  74. bisInspCdepCon.setRgstrId(id);
  75. bisInspCdepConService.insert(bisInspCdepCon);
  76. }
  77. return buildSuccessResponse(bisInspCdepCon);
  78. }
  79. }