b1ec20effc4496a5fbbffe88be2cb24b2ff5a18d.svn-base 3.6 KB

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