package cn.com.goldenwater.dcproj.controller.samrmp; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.model.BisInspSamrmpRgstr; import cn.com.goldenwater.dcproj.model.BisInspSamrmpRgstrSmrmp; import cn.com.goldenwater.dcproj.param.BisInspSamrmpRgstrSmrmpParam; import cn.com.goldenwater.dcproj.service.BisInspSamrmpRgstrService; import cn.com.goldenwater.dcproj.service.BisInspSamrmpRgstrSmrmpService; import cn.com.goldenwater.id.util.UuidUtil; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.util.List; /** * @author lune * @date 2020-9-11 */ @Api(value = "BIS 中小河流治理项目抽查情况管理",tags="BIS 中小河流治理项目抽查情况管理") @RestController @RequestMapping("/bis/insp/samrmp/rgstr/smrmp") public class BisInspSamrmpRgstrSmrmpController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspSamrmpRgstrSmrmpService bisInspSamrmpRgstrSmrmpService; @Autowired private BisInspSamrmpRgstrService bisInspSamrmpRgstrService; @ApiOperation(value = "添加/修改中小河流治理项目抽查情况") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspSamrmpRgstrSmrmp", value = "BisInspSamrmpRgstrSmrmp", required = true) @RequestBody BisInspSamrmpRgstrSmrmp bisInspSamrmpRgstrSmrmp) { if(StringUtils.isBlank(bisInspSamrmpRgstrSmrmp.getId())) { // 生成uuid String uuid = UuidUtil.uuid(); bisInspSamrmpRgstrSmrmp.setId(uuid); bisInspSamrmpRgstrSmrmpService.insert(bisInspSamrmpRgstrSmrmp); }else{ bisInspSamrmpRgstrSmrmpService.update(bisInspSamrmpRgstrSmrmp); } if (StringUtils.isNotBlank(bisInspSamrmpRgstrSmrmp.getRgstrId())) { BisInspSamrmpRgstr rgstr = bisInspSamrmpRgstrService.get(bisInspSamrmpRgstrSmrmp.getRgstrId()); if (rgstr != null) { rgstr.setSmrmpState(bisInspSamrmpRgstrSmrmp.getStatus()); if (!"2".equals(rgstr.getState())) { rgstr.setState("1"); } bisInspSamrmpRgstrService.update(rgstr); } } return buildSuccessResponse(bisInspSamrmpRgstrSmrmp); } @ApiOperation(value = "根据ID删除中小河流治理项目抽查情况") @RequestMapping(value = "/del/{id}", method = RequestMethod.GET) public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { int ret = bisInspSamrmpRgstrSmrmpService.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) { BisInspSamrmpRgstrSmrmp bisInspSamrmpRgstrSmrmp = bisInspSamrmpRgstrSmrmpService.get(id); return buildSuccessResponse(bisInspSamrmpRgstrSmrmp); } @ApiOperation(value = "获取中小河流治理项目抽查情况(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisInspSamrmpRgstrSmrmpParam", value = "bisInspSamrmpRgstrSmrmpParam", required = true) @RequestBody BisInspSamrmpRgstrSmrmpParam bisInspSamrmpRgstrSmrmpParam) { List bisInspSamrmpRgstrSmrmpList = bisInspSamrmpRgstrSmrmpService.findList(bisInspSamrmpRgstrSmrmpParam); return buildSuccessResponse(bisInspSamrmpRgstrSmrmpList); } @ApiOperation(value = "获取中小河流治理项目抽查情况(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisInspSamrmpRgstrSmrmpParam", value = "bisInspSamrmpRgstrSmrmpParam", required = true) @RequestBody BisInspSamrmpRgstrSmrmpParam bisInspSamrmpRgstrSmrmpParam) { PageInfo bisInspSamrmpRgstrSmrmpList = bisInspSamrmpRgstrSmrmpService.findPageInfo(bisInspSamrmpRgstrSmrmpParam); return buildSuccessResponse(bisInspSamrmpRgstrSmrmpList); } @ApiOperation(value = "根据登记表id获取取水单位用水情况") @RequestMapping(value = "/getBy/{rgstrId}", method = RequestMethod.GET) public BaseResponse getBy(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId, HttpServletRequest request) { if(StringUtils.isBlank(rgstrId)) { return buildFailResponse(); } BisInspSamrmpRgstrSmrmpParam param = new BisInspSamrmpRgstrSmrmpParam(); param.setRgstrId(rgstrId); BisInspSamrmpRgstrSmrmp info = this.bisInspSamrmpRgstrSmrmpService.getBy(param); return buildSuccessResponse(info); } }