package cn.com.goldenwater.dcproj.controller.wrwx; import cn.com.goldenwater.dcproj.model.BisInspWrwxRgstrWtut; import cn.com.goldenwater.dcproj.param.BisInspWrwxRgstrWtutParam; import cn.com.goldenwater.dcproj.service.BisInspWrwxRgstrWtutService; 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/wrwx/wtut") public class BisInspWrwxRgstrWtutController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspWrwxRgstrWtutService bisInspWrwxRgstrWtutService; @ApiOperation(value = "添加或修改取用水统计-市或县") @RequestMapping(value = "/add", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspWrwxRgstrWtut", value = "BisInspWrwxRgstrWtut", required = true) @RequestBody BisInspWrwxRgstrWtut bisInspWrwxRgstrWtut) { if (StringUtils.isBlank(bisInspWrwxRgstrWtut.getRgstrId())){ return buildFailResponse(); } // 根据有无主键,来新增、更新信息 int ret = 0; if(StringUtils.isBlank(bisInspWrwxRgstrWtut.getId())){ BisInspWrwxRgstrWtutParam param = new BisInspWrwxRgstrWtutParam(); param.setRgstrId(bisInspWrwxRgstrWtut.getRgstrId()); BisInspWrwxRgstrWtut wtut = bisInspWrwxRgstrWtutService.getBy(param); if (null == wtut){ ret = bisInspWrwxRgstrWtutService.insert(bisInspWrwxRgstrWtut); } else { bisInspWrwxRgstrWtut.setId(wtut.getId()); ret = bisInspWrwxRgstrWtutService.update(bisInspWrwxRgstrWtut); } } else { ret = bisInspWrwxRgstrWtutService.update(bisInspWrwxRgstrWtut); } return buildSuccessResponse(bisInspWrwxRgstrWtut); } @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 = bisInspWrwxRgstrWtutService.delete(id); return buildSuccessResponse(); } @ApiOperation(value = "根据ID获取取用水统计-市或县(单表)") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { BisInspWrwxRgstrWtut bisInspWrwxRgstrWtut = bisInspWrwxRgstrWtutService.get(id); if (null == bisInspWrwxRgstrWtut){ bisInspWrwxRgstrWtut = new BisInspWrwxRgstrWtut(); bisInspWrwxRgstrWtut.setRgstrId(id); bisInspWrwxRgstrWtutService.insert(bisInspWrwxRgstrWtut); } return buildSuccessResponse(bisInspWrwxRgstrWtut); } }