package cn.com.goldenwater.dcproj.controller.wiu; import cn.com.goldenwater.dcproj.model.BisInspWiuRgstr; import cn.com.goldenwater.dcproj.model.BisInspWiuRgstrApprInfo; import cn.com.goldenwater.dcproj.param.BisInspWiuRgstrApprInfoParam; import cn.com.goldenwater.dcproj.service.BisInspWiuRgstrApprInfoService; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.service.BisInspWiuRgstrService; 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.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; import javax.servlet.http.HttpServletRequest; import java.util.Date; import java.util.List; /** * @author lune * @date 2019-8-9 */ @Api(value = "BIS 取水许可审批监管情况管理",tags="BIS 取水许可审批监管情况管理") @RestController @RequestMapping("/bis/insp/wiu/rgstr/appr/info") public class BisInspWiuRgstrApprInfoController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspWiuRgstrApprInfoService bisInspWiuRgstrApprInfoService; @Autowired private BisInspWiuRgstrService wiuRgstrService; @ApiOperation(value = "添加/修改取水许可审批监管情况") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspWiuRgstrApprInfo", value = "BisInspWiuRgstrApprInfo", required = true) @RequestBody BisInspWiuRgstrApprInfo bisInspWiuRgstrApprInfo) { if(StringUtils.isBlank(bisInspWiuRgstrApprInfo.getId())) { String uuid = UuidUtil.uuid(); // 生成uuid bisInspWiuRgstrApprInfo.setId(uuid); bisInspWiuRgstrApprInfo.setInTm(new Date()); bisInspWiuRgstrApprInfo.setUpTm(new Date()); bisInspWiuRgstrApprInfoService.insert(bisInspWiuRgstrApprInfo); }else{ bisInspWiuRgstrApprInfo.setUpTm(new Date()); bisInspWiuRgstrApprInfoService.update(bisInspWiuRgstrApprInfo); } if (StringUtils.isNotBlank(bisInspWiuRgstrApprInfo.getRgstrId())) { BisInspWiuRgstr rgstr = wiuRgstrService.get(bisInspWiuRgstrApprInfo.getRgstrId()); if (rgstr != null) { rgstr.setApprInfoStat(bisInspWiuRgstrApprInfo.getDataStat()); if (!"2".equals(rgstr.getState())) { rgstr.setState("1"); } wiuRgstrService.update(rgstr); } } return buildSuccessResponse(bisInspWiuRgstrApprInfo); } @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 = bisInspWiuRgstrApprInfoService.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) { BisInspWiuRgstrApprInfo bisInspWiuRgstrApprInfo = bisInspWiuRgstrApprInfoService.get(id); return buildSuccessResponse(bisInspWiuRgstrApprInfo); } @ApiOperation(value = "获取取水许可审批监管情况(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisInspWiuRgstrApprInfoParam", value = "bisInspWiuRgstrApprInfoParam", required = true) @RequestBody BisInspWiuRgstrApprInfoParam bisInspWiuRgstrApprInfoParam) { List bisInspWiuRgstrApprInfoList = bisInspWiuRgstrApprInfoService.findList(bisInspWiuRgstrApprInfoParam); return buildSuccessResponse(bisInspWiuRgstrApprInfoList); } @ApiOperation(value = "获取取水许可审批监管情况(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisInspWiuRgstrApprInfoParam", value = "bisInspWiuRgstrApprInfoParam", required = true) @RequestBody BisInspWiuRgstrApprInfoParam bisInspWiuRgstrApprInfoParam) { PageInfo bisInspWiuRgstrApprInfoList = bisInspWiuRgstrApprInfoService.findPageInfo(bisInspWiuRgstrApprInfoParam); return buildSuccessResponse(bisInspWiuRgstrApprInfoList); } @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(); } BisInspWiuRgstrApprInfoParam param = new BisInspWiuRgstrApprInfoParam(); param.setRgstrId(rgstrId); BisInspWiuRgstrApprInfo info = this.bisInspWiuRgstrApprInfoService.getBy(param); return buildSuccessResponse(info); } }