package cn.com.goldenwater.dcproj.controller.hyst; import cn.com.goldenwater.dcproj.model.BisInspHystInfo; import cn.com.goldenwater.dcproj.model.BisInspHystSfmngInfo; import cn.com.goldenwater.dcproj.param.BisInspHystSfmngInfoParam; import cn.com.goldenwater.dcproj.service.BisInspHystInfoService; import cn.com.goldenwater.dcproj.service.BisInspHystSfmngInfoService; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.id.util.UuidUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.apache.commons.lang3.StringUtils; import com.github.pagehelper.PageInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.Assert; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.Date; import java.util.List; /** * @author lune * @date 2021-3-2 */ @Api(value = "BIS 小水电安全管理情况表管理",tags="BIS 小水电安全管理情况表管理") @RestController @RequestMapping("/bis/insp/hyst/sfmng/info") public class BisInspHystSfmngInfoController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspHystSfmngInfoService bisInspHystSfmngInfoService; @Autowired private BisInspHystInfoService bisInspHystInfoService; @ApiOperation(value = "添加/修改小水电安全管理情况表") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspHystSfmngInfo", value = "BisInspHystSfmngInfo", required = true) @RequestBody BisInspHystSfmngInfo bisInspHystSfmngInfo) { if(StringUtils.isBlank(bisInspHystSfmngInfo.getId())) { // 生成uuid String uuid = UuidUtil.uuid(); bisInspHystSfmngInfo.setId(uuid); bisInspHystSfmngInfo.setIntm(new Date()); bisInspHystSfmngInfoService.insert(bisInspHystSfmngInfo); }else{ bisInspHystSfmngInfo.setUptm(new Date()); bisInspHystSfmngInfoService.update(bisInspHystSfmngInfo); } //更新小水电填报状态 String rgstrId = bisInspHystSfmngInfo.getRgstrId(); BisInspHystInfo bisInspHystInfo = new BisInspHystInfo(); bisInspHystInfo.setId(rgstrId); bisInspHystInfo.setSfmngState(bisInspHystSfmngInfo.getStatus()); bisInspHystInfoService.update(bisInspHystInfo); return buildSuccessResponse(bisInspHystSfmngInfo); } @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 = bisInspHystSfmngInfoService.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) { BisInspHystSfmngInfo bisInspHystSfmngInfo = bisInspHystSfmngInfoService.get(id); return buildSuccessResponse(bisInspHystSfmngInfo); } @ApiOperation(value = "根据rgstrId获取小水电安全管理情况表(单表)") @RequestMapping(value = "/getBy/{id}", method = RequestMethod.GET) public BaseResponse getBy(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { BisInspHystSfmngInfoParam bisInspHystSfmngInfoParam = new BisInspHystSfmngInfoParam(); bisInspHystSfmngInfoParam.setRgstrId(id); BisInspHystSfmngInfo by = bisInspHystSfmngInfoService.getBy(bisInspHystSfmngInfoParam); return buildSuccessResponse(by); } @ApiOperation(value = "获取小水电安全管理情况表(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisInspHystSfmngInfoParam", value = "bisInspHystSfmngInfoParam", required = true) @RequestBody BisInspHystSfmngInfoParam bisInspHystSfmngInfoParam) { List bisInspHystSfmngInfoList = bisInspHystSfmngInfoService.findList(bisInspHystSfmngInfoParam); return buildSuccessResponse(bisInspHystSfmngInfoList); } @ApiOperation(value = "获取小水电安全管理情况表(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisInspHystSfmngInfoParam", value = "bisInspHystSfmngInfoParam", required = true) @RequestBody BisInspHystSfmngInfoParam bisInspHystSfmngInfoParam) { PageInfo bisInspHystSfmngInfoList = bisInspHystSfmngInfoService.findPageInfo(bisInspHystSfmngInfoParam); return buildSuccessResponse(bisInspHystSfmngInfoList); } }