7d3ef541ca7f3fc5a56ff4dda7f54e6e58ea913b.svn-base 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package cn.com.goldenwater.dcproj.controller.wrwx;
  2. import cn.com.goldenwater.dcproj.model.BisInspWrwxRgstrWtup;
  3. import cn.com.goldenwater.dcproj.param.BisInspWrwxRgstrWtupParam;
  4. import cn.com.goldenwater.dcproj.service.BisInspWrwxRgstrWtupService;
  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.slf4j.Logger;
  11. import org.slf4j.LoggerFactory;
  12. import org.apache.commons.lang3.StringUtils;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.web.bind.annotation.PathVariable;
  15. import org.springframework.web.bind.annotation.RequestBody;
  16. import org.springframework.web.bind.annotation.RequestMapping;
  17. import org.springframework.web.bind.annotation.RequestMethod;
  18. import org.springframework.web.bind.annotation.RestController;
  19. /**
  20. * @author lhc
  21. * @date 2020-9-23
  22. */
  23. @Api(value = "用水强度控制实施-市或县管理",tags="用水强度控制实施-市或县管理")
  24. @RestController
  25. @RequestMapping("/bis/insp/wrwx/wtup")
  26. public class BisInspWrwxRgstrWtupController extends BaseController {
  27. private Logger logger = LoggerFactory.getLogger(getClass());
  28. @Autowired
  29. private BisInspWrwxRgstrWtupService bisInspWrwxRgstrWtupService;
  30. @ApiOperation(value = "添加或修改用水强度控制实施-市或县")
  31. @RequestMapping(value = "", method = RequestMethod.POST)
  32. public BaseResponse<BisInspWrwxRgstrWtup> insert(@ApiParam(name = "bisInspWrwxRgstrWtup", value = "BisInspWrwxRgstrWtup", required = true) @RequestBody BisInspWrwxRgstrWtup bisInspWrwxRgstrWtup) {
  33. if (StringUtils.isBlank(bisInspWrwxRgstrWtup.getRgstrId())){
  34. return buildFailResponse();
  35. }
  36. // 根据有无主键,来新增、更新信息
  37. int ret = 0;
  38. if(StringUtils.isBlank(bisInspWrwxRgstrWtup.getId())){
  39. BisInspWrwxRgstrWtupParam param = new BisInspWrwxRgstrWtupParam();
  40. param.setRgstrId(bisInspWrwxRgstrWtup.getRgstrId());
  41. BisInspWrwxRgstrWtup wtup = bisInspWrwxRgstrWtupService.getBy(param);
  42. if (null == wtup){
  43. ret = bisInspWrwxRgstrWtupService.insert(bisInspWrwxRgstrWtup);
  44. } else {
  45. bisInspWrwxRgstrWtup.setId(wtup.getId());
  46. ret = bisInspWrwxRgstrWtupService.update(bisInspWrwxRgstrWtup);
  47. }
  48. } else {
  49. ret = bisInspWrwxRgstrWtupService.update(bisInspWrwxRgstrWtup);
  50. }
  51. return buildSuccessResponse(bisInspWrwxRgstrWtup);
  52. }
  53. @ApiOperation(value = "根据ID删除用水强度控制实施-市或县")
  54. @RequestMapping(value = "delete/{id}", method = RequestMethod.POST)
  55. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  56. int ret = bisInspWrwxRgstrWtupService.delete(id);
  57. return buildSuccessResponse();
  58. }
  59. @ApiOperation(value = "根据ID获取用水强度控制实施-市或县(单表)")
  60. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  61. public BaseResponse<BisInspWrwxRgstrWtup> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  62. BisInspWrwxRgstrWtup bisInspWrwxRgstrWtup = bisInspWrwxRgstrWtupService.get(id);
  63. if (null == bisInspWrwxRgstrWtup){
  64. bisInspWrwxRgstrWtup = new BisInspWrwxRgstrWtup();
  65. bisInspWrwxRgstrWtup.setRgstrId(id);
  66. bisInspWrwxRgstrWtupService.insert(bisInspWrwxRgstrWtup);
  67. }
  68. return buildSuccessResponse(bisInspWrwxRgstrWtup);
  69. }
  70. }