package cn.com.goldenwater.dcproj.controller.cdep; import cn.com.goldenwater.dcproj.model.BisInspCdepCap; import cn.com.goldenwater.dcproj.param.BisInspCdepCapParam; import cn.com.goldenwater.dcproj.service.BisInspCdepCapService; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; 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.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.RestController; /** * @author zhangcheng * @date 2020-11-19 */ @Api(value = "检测能力岩土工程管理",tags="检测能力岩土工程管理") @RestController @RequestMapping("/bis/insp/cdep/cap") public class BisInspCdepCapController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspCdepCapService bisInspCdepCapService; @ApiOperation(value = "添加或修改检测能力岩土工程表(新疆)") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspCdepCap", value = "BisInspCdepCap", required = true) @RequestBody BisInspCdepCap bisInspCdepCap) { if (StringUtils.isBlank(bisInspCdepCap.getRgstrId())){ return buildFailResponse(); } // 根据有无主键,来新增、更新信息 int ret = 0; if(StringUtils.isBlank(bisInspCdepCap.getId())){ BisInspCdepCapParam param = new BisInspCdepCapParam(); param.setRgstrId(bisInspCdepCap.getRgstrId()); BisInspCdepCap cap = bisInspCdepCapService.getBy(param); if (null == cap){ ret = bisInspCdepCapService.insert(bisInspCdepCap); } else { bisInspCdepCap.setId(cap.getId()); ret = bisInspCdepCapService.update(bisInspCdepCap); } } else { ret = bisInspCdepCapService.update(bisInspCdepCap); } return buildSuccessResponse(bisInspCdepCap); } @ApiOperation(value = "根据ID删除xxx") @RequestMapping(value = "delete/{id}", method = RequestMethod.POST) public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { int ret = bisInspCdepCapService.delete(id); return buildSuccessResponse(); } @ApiOperation(value = "更新xxx信息") @RequestMapping(value = "/update", method = RequestMethod.POST) public BaseResponse update(@ApiParam(name = "bisInspCdepCap", value = "BisInspCdepCap", required = true) @RequestBody BisInspCdepCap bisInspCdepCap) { Assert.notNull(bisInspCdepCap.getId(), "主键id为必填参数"); int ret = bisInspCdepCapService.update(bisInspCdepCap); return buildSuccessResponse(bisInspCdepCap); } @ApiOperation(value = "根据ID获取检测能力岩土工程表(新疆)(单表)") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { BisInspCdepCap bisInspCdepCap = bisInspCdepCapService.get(id); if (null == bisInspCdepCap){ bisInspCdepCap = new BisInspCdepCap(); bisInspCdepCap.setRgstrId(id); bisInspCdepCapService.insert(bisInspCdepCap); } return buildSuccessResponse(bisInspCdepCap); } }