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.BisInspRsfcoRgstrBaseInfo; import cn.com.goldenwater.dcproj.param.BisInspRsfcoRgstrBaseInfoParam; import cn.com.goldenwater.dcproj.service.BisInspRsfcoRgstrBaseInfoService; import cn.com.goldenwater.dcproj.service.BisInspRsfcoRgstrService; import cn.com.goldenwater.id.util.UuidUtil; import cn.com.goldenwater.target.CheckException; 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.Date; import java.util.List; /** * @author lune * @date 2021年3月29日 */ @Api(value = "BIS 水库基本情况表-新管理", tags = "BIS 水库基本情况表-新管理") @RestController @RequestMapping("/bis/insp/rsfco/rgstr/base/info") public class BisInspRsfcoRgstrBaseInfoController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspRsfcoRgstrBaseInfoService bisInspRsfcoRgstrBaseInfoService; @Autowired private BisInspRsfcoRgstrService bisInspRsfcoRgstrService; @ApiOperation(value = "添加/修改水库基本情况表-新") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspRsfcoRgstrBaseInfo", value = "BisInspRsfcoRgstrBaseInfo", required = true) @RequestBody BisInspRsfcoRgstrBaseInfo bisInspRsfcoRgstrBaseInfo) { if (StringUtils.isNotBlank(bisInspRsfcoRgstrBaseInfo.getRgstrId())) { BisInspRsfcoRgstr rgstr = bisInspRsfcoRgstrService.get(bisInspRsfcoRgstrBaseInfo.getRgstrId()); if (rgstr != null) { rgstr.setAdCode(bisInspRsfcoRgstrBaseInfo.getAdCode()); rgstr.setLocation(bisInspRsfcoRgstrBaseInfo.getLocation()); rgstr.setEngScal(bisInspRsfcoRgstrBaseInfo.getEngScal()); rgstr.setBaseInfoState(bisInspRsfcoRgstrBaseInfo.getStatus()); if (!"2".equals(rgstr.getState())) { rgstr.setState("1"); } bisInspRsfcoRgstrService.update(rgstr); } } else { return buildFailResponse(new IllegalArgumentException("rgstrId 为必传字段")); } if (StringUtils.isBlank(bisInspRsfcoRgstrBaseInfo.getId())) { // 生成uuid String uuid = UuidUtil.uuid(); bisInspRsfcoRgstrBaseInfo.setId(uuid); bisInspRsfcoRgstrBaseInfo.setIntm(new Date()); bisInspRsfcoRgstrBaseInfo.setUptm(new Date()); bisInspRsfcoRgstrBaseInfoService.insert(bisInspRsfcoRgstrBaseInfo); } else { bisInspRsfcoRgstrBaseInfo.setUptm(new Date()); bisInspRsfcoRgstrBaseInfoService.update(bisInspRsfcoRgstrBaseInfo); } return buildSuccessResponse(bisInspRsfcoRgstrBaseInfo); } @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 = bisInspRsfcoRgstrBaseInfoService.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) { BisInspRsfcoRgstrBaseInfo bisInspRsfcoRgstrBaseInfo = bisInspRsfcoRgstrBaseInfoService.get(id); return buildSuccessResponse(bisInspRsfcoRgstrBaseInfo); } @ApiOperation(value = "获取水库基本情况表-新(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisInspRsfcoRgstrBaseInfoParam", value = "bisInspRsfcoRgstrBaseInfoParam", required = true) @RequestBody BisInspRsfcoRgstrBaseInfoParam bisInspRsfcoRgstrBaseInfoParam) { List bisInspRsfcoRgstrBaseInfoList = bisInspRsfcoRgstrBaseInfoService.findList(bisInspRsfcoRgstrBaseInfoParam); return buildSuccessResponse(bisInspRsfcoRgstrBaseInfoList); } @ApiOperation(value = "获取水库基本情况表-新(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisInspRsfcoRgstrBaseInfoParam", value = "bisInspRsfcoRgstrBaseInfoParam", required = true) @RequestBody BisInspRsfcoRgstrBaseInfoParam bisInspRsfcoRgstrBaseInfoParam) { PageInfo bisInspRsfcoRgstrBaseInfoList = bisInspRsfcoRgstrBaseInfoService.findPageInfo(bisInspRsfcoRgstrBaseInfoParam); return buildSuccessResponse(bisInspRsfcoRgstrBaseInfoList); } @ApiOperation(value = "根据ID获取水库基本情况表-新(单表)") @RequestMapping(value = "/getBy", method = RequestMethod.POST) public BaseResponse getBy(@ApiParam(name = "bisInspRsfcoRgstrBaseInfoParam", value = "bisInspRsfcoRgstrBaseInfoParam", required = true) @RequestBody BisInspRsfcoRgstrBaseInfoParam bisInspRsfcoRgstrBaseInfoParam) { BisInspRsfcoRgstrBaseInfo bisInspRsfcoRgstrBaseInfo = bisInspRsfcoRgstrBaseInfoService.getBy(bisInspRsfcoRgstrBaseInfoParam); return buildSuccessResponse(bisInspRsfcoRgstrBaseInfo); } }