package cn.com.goldenwater.dcproj.controller.rsfco; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.model.BisInspRsfcoRgstr; import cn.com.goldenwater.dcproj.model.BisInspRsfcoRgstrFcs; import cn.com.goldenwater.dcproj.param.BisInspRsfcoRgstrFcsParam; import cn.com.goldenwater.dcproj.service.BisInspRsfcoRgstrFcsService; import cn.com.goldenwater.dcproj.service.BisInspRsfcoRgstrService; 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 java.util.List; /** * @author lune * @date 2021年3月29日 */ @Api(value = "BIS 水库防洪调度监督检查-新管理",tags="BIS 水库防洪调度监督检查-新管理") @RestController @RequestMapping("/bis/insp/rsfco/rgstr/fcs") public class BisInspRsfcoRgstrFcsController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspRsfcoRgstrFcsService bisInspRsfcoRgstrFcsService; @Autowired private BisInspRsfcoRgstrService bisInspRsfcoRgstrService; @ApiOperation(value = "添加/修改水库防洪调度监督检查-新") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspRsfcoRgstrFcs", value = "BisInspRsfcoRgstrFcs", required = true) @RequestBody BisInspRsfcoRgstrFcs bisInspRsfcoRgstrFcs) { if (StringUtils.isNotBlank(bisInspRsfcoRgstrFcs.getRgstrId())){ BisInspRsfcoRgstr rgstr = bisInspRsfcoRgstrService.get(bisInspRsfcoRgstrFcs.getRgstrId()); if (rgstr != null){ rgstr.setFcsState(bisInspRsfcoRgstrFcs.getStatus()); if (!"2".equals(rgstr.getState())) { rgstr.setState("1"); if (StringUtils.isNotBlank(bisInspRsfcoRgstrFcs.getStatus())) { rgstr.setFcsState( bisInspRsfcoRgstrFcs.getStatus()); } } bisInspRsfcoRgstrService.update(rgstr); } } else { return buildFailResponse(new IllegalArgumentException("rgstrId 为必传字段")); } if(StringUtils.isBlank(bisInspRsfcoRgstrFcs.getId())) { // 生成uuid String uuid = UuidUtil.uuid(); bisInspRsfcoRgstrFcs.setId(uuid); bisInspRsfcoRgstrFcsService.insert(bisInspRsfcoRgstrFcs); }else{ bisInspRsfcoRgstrFcsService.update(bisInspRsfcoRgstrFcs); } return buildSuccessResponse(bisInspRsfcoRgstrFcs); } @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 = bisInspRsfcoRgstrFcsService.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) { BisInspRsfcoRgstrFcs bisInspRsfcoRgstrFcs = bisInspRsfcoRgstrFcsService.getWith(id); return buildSuccessResponse(bisInspRsfcoRgstrFcs); } @ApiOperation(value = "根据ID获取水库防洪调度监督检查-新(单表)") @RequestMapping(value = "/getBy/{id}", method = RequestMethod.GET) public BaseResponse getBy(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { if(StringUtils.isBlank(id)) { return buildFailResponse(); } BisInspRsfcoRgstrFcsParam fcs = new BisInspRsfcoRgstrFcsParam(); fcs.setRgstrId(id); BisInspRsfcoRgstrFcs bisInspRsfcoRgstrFcs = bisInspRsfcoRgstrFcsService.getBy(fcs); return buildSuccessResponse(bisInspRsfcoRgstrFcs); } @ApiOperation(value = "根据ID获取水库防洪调度监督检查-新(单表)") @RequestMapping(value = "getWith/{id}", method = RequestMethod.GET) public BaseResponse getWith(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { BisInspRsfcoRgstrFcs bisInspRsfcoRgstrFcs = bisInspRsfcoRgstrFcsService.get(id); return buildSuccessResponse(bisInspRsfcoRgstrFcs); } @ApiOperation(value = "获取水库防洪调度监督检查-新(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisInspRsfcoRgstrFcsParam", value = "bisInspRsfcoRgstrFcsParam", required = true) @RequestBody BisInspRsfcoRgstrFcsParam bisInspRsfcoRgstrFcsParam) { List bisInspRsfcoRgstrFcsList = bisInspRsfcoRgstrFcsService.findList(bisInspRsfcoRgstrFcsParam); return buildSuccessResponse(bisInspRsfcoRgstrFcsList); } @ApiOperation(value = "获取水库防洪调度监督检查-新(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisInspRsfcoRgstrFcsParam", value = "bisInspRsfcoRgstrFcsParam", required = true) @RequestBody BisInspRsfcoRgstrFcsParam bisInspRsfcoRgstrFcsParam) { PageInfo bisInspRsfcoRgstrFcsList = bisInspRsfcoRgstrFcsService.findPageInfo(bisInspRsfcoRgstrFcsParam); return buildSuccessResponse(bisInspRsfcoRgstrFcsList); } }