| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- package cn.com.goldenwater.dcproj.controller.wrws;
- import cn.com.goldenwater.dcproj.model.BisInspWrwsRgstrWtup;
- import cn.com.goldenwater.dcproj.param.BisInspWrwsRgstrWtupParam;
- import cn.com.goldenwater.dcproj.service.BisInspWrwsRgstrWtupService;
- import cn.com.goldenwater.core.web.BaseController;
- import cn.com.goldenwater.core.web.BaseResponse;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- /**
- * @author lhc
- * @date 2020-9-23
- */
- @Api(value = "用水强度控制实施-市或县管理",tags="用水强度控制实施-市或县管理")
- @RestController
- @RequestMapping("/bis/insp/wrws/wtup")
- public class BisInspWrwsRgstrWtupController extends BaseController {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- private BisInspWrwsRgstrWtupService bisInspWrwsRgstrWtupService;
- @ApiOperation(value = "添加或修改用水强度控制实施-市或县")
- @RequestMapping(value = "", method = RequestMethod.POST)
- public BaseResponse<BisInspWrwsRgstrWtup> insert(@ApiParam(name = "bisInspWrwsRgstrWtup", value = "BisInspWrwsRgstrWtup", required = true) @RequestBody BisInspWrwsRgstrWtup bisInspWrwsRgstrWtup) {
- if (StringUtils.isBlank(bisInspWrwsRgstrWtup.getRgstrId())){
- return buildFailResponse();
- }
- // 根据有无主键,来新增、更新信息
- int ret = 0;
- if(StringUtils.isBlank(bisInspWrwsRgstrWtup.getId())){
- BisInspWrwsRgstrWtupParam param = new BisInspWrwsRgstrWtupParam();
- param.setRgstrId(bisInspWrwsRgstrWtup.getRgstrId());
- BisInspWrwsRgstrWtup wtup = bisInspWrwsRgstrWtupService.getBy(param);
- if (null == wtup){
- ret = bisInspWrwsRgstrWtupService.insert(bisInspWrwsRgstrWtup);
- } else {
- bisInspWrwsRgstrWtup.setId(wtup.getId());
- ret = bisInspWrwsRgstrWtupService.update(bisInspWrwsRgstrWtup);
- }
- } else {
- ret = bisInspWrwsRgstrWtupService.update(bisInspWrwsRgstrWtup);
- }
- return buildSuccessResponse(bisInspWrwsRgstrWtup);
- }
- @ApiOperation(value = "根据ID删除用水强度控制实施-市或县")
- @RequestMapping(value = "delete/{id}", method = RequestMethod.POST)
- public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- int ret = bisInspWrwsRgstrWtupService.delete(id);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "根据ID获取用水强度控制实施-市或县(单表)")
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- public BaseResponse<BisInspWrwsRgstrWtup> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- BisInspWrwsRgstrWtup bisInspWrwsRgstrWtup = bisInspWrwsRgstrWtupService.get(id);
- if (null == bisInspWrwsRgstrWtup){
- bisInspWrwsRgstrWtup = new BisInspWrwsRgstrWtup();
- bisInspWrwsRgstrWtup.setRgstrId(id);
- bisInspWrwsRgstrWtupService.insert(bisInspWrwsRgstrWtup);
- }
- return buildSuccessResponse(bisInspWrwsRgstrWtup);
- }
- }
|