27c9eb0f0d1d4388c27fd5345061b5c32622bd40.svn-base 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package cn.com.goldenwater.dcproj.controller.wrws;
  2. import cn.com.goldenwater.dcproj.model.BisInspWrwsRgstrWg;
  3. import cn.com.goldenwater.dcproj.param.BisInspWrwsRgstrWgParam;
  4. import cn.com.goldenwater.dcproj.service.BisInspWrwsRgstrWgService;
  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/wrws/wg")
  26. public class BisInspWrwsRgstrWgController extends BaseController {
  27. private Logger logger = LoggerFactory.getLogger(getClass());
  28. @Autowired
  29. private BisInspWrwsRgstrWgService bisInspWrwsRgstrWgService;
  30. @ApiOperation(value = "添加或修改取水口监管-市或县")
  31. @RequestMapping(value = "", method = RequestMethod.POST)
  32. public BaseResponse<BisInspWrwsRgstrWg> insert(@ApiParam(name = "bisInspWrwsRgstrWg", value = "BisInspWrwsRgstrWg", required = true) @RequestBody BisInspWrwsRgstrWg bisInspWrwsRgstrWg) {
  33. if (StringUtils.isBlank(bisInspWrwsRgstrWg.getRgstrId())){
  34. return buildFailResponse();
  35. }
  36. // 根据有无主键,来新增、更新信息
  37. int ret = 0;
  38. if(StringUtils.isBlank(bisInspWrwsRgstrWg.getId())){
  39. BisInspWrwsRgstrWgParam param = new BisInspWrwsRgstrWgParam();
  40. param.setRgstrId(bisInspWrwsRgstrWg.getRgstrId());
  41. BisInspWrwsRgstrWg wg = bisInspWrwsRgstrWgService.getBy(param);
  42. if (null == wg){
  43. ret = bisInspWrwsRgstrWgService.insert(bisInspWrwsRgstrWg);
  44. } else {
  45. bisInspWrwsRgstrWg.setId(wg.getId());
  46. ret = bisInspWrwsRgstrWgService.update(bisInspWrwsRgstrWg);
  47. }
  48. } else {
  49. ret = bisInspWrwsRgstrWgService.update(bisInspWrwsRgstrWg);
  50. }
  51. return buildSuccessResponse(bisInspWrwsRgstrWg);
  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 = bisInspWrwsRgstrWgService.delete(id);
  57. return buildSuccessResponse();
  58. }
  59. @ApiOperation(value = "根据ID获取取水口监管-市或县(单表)")
  60. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  61. public BaseResponse<BisInspWrwsRgstrWg> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  62. BisInspWrwsRgstrWg bisInspWrwsRgstrWg = bisInspWrwsRgstrWgService.get(id);
  63. if (null == bisInspWrwsRgstrWg){
  64. bisInspWrwsRgstrWg = new BisInspWrwsRgstrWg();
  65. bisInspWrwsRgstrWg.setRgstrId(id);
  66. bisInspWrwsRgstrWgService.insert(bisInspWrwsRgstrWg);
  67. }
  68. return buildSuccessResponse(bisInspWrwsRgstrWg);
  69. }
  70. }