package cn.com.goldenwater.dcproj.controller.anze; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.dto.AttAnzeUnderwritingDto; import cn.com.goldenwater.dcproj.model.AttProjectInsurance; import cn.com.goldenwater.dcproj.param.AttAnzeUnderwritingParam; import cn.com.goldenwater.dcproj.param.AttProjectInsuranceParam; import cn.com.goldenwater.dcproj.service.AttProjectInsuranceService; import cn.com.goldenwater.dcproj.utils.DateUtils; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.*; import java.util.Date; import java.util.List; import java.util.Optional; /** * @author lql * @date 2026-4-21 */ @Slf4j @Api(value = "水利工程管理", tags = "水利工程管理") @RestController @RequestMapping("/att/project/insurance") public class AttProjectInsuranceController extends BaseController { @Autowired private AttProjectInsuranceService attProjectInsuranceService; @ApiOperation(value = "添加水利工程") @RequestMapping(value = "/add", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "attProjectInsurance", value = "AttProjectInsurance", required = true) @RequestBody AttProjectInsurance attProjectInsurance) { int ret = attProjectInsuranceService.insert(attProjectInsurance); return buildSuccessResponse(attProjectInsurance); } @ApiOperation(value = "根据ID删除水利工程") @RequestMapping(value = "delete/{id}", method = RequestMethod.POST) public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { int ret = attProjectInsuranceService.delete(id); return buildSuccessResponse(); } @ApiOperation(value = "更新水利工程信息") @RequestMapping(value = "/update", method = RequestMethod.POST) public BaseResponse update(@ApiParam(name = "attProjectInsurance", value = "AttProjectInsurance", required = true) @RequestBody AttProjectInsurance attProjectInsurance) { Assert.notNull(attProjectInsurance.getId(), "主键id为必填参数"); int ret = attProjectInsuranceService.update(attProjectInsurance); return buildSuccessResponse(attProjectInsurance); } @ApiOperation(value = "根据ID获取水利工程(单表)") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { AttProjectInsurance attProjectInsurance = attProjectInsuranceService.get(id); return buildSuccessResponse(attProjectInsurance); } @ApiOperation(value = "根据ID获取水利工程(分页)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse pageList(@ApiParam(name = "attProjectInsuranceParam", value = "attProjectInsuranceParam", required = true) @RequestBody AttProjectInsuranceParam param) { PageInfo attProjectInsurance = attProjectInsuranceService.findPageInfo(param); return buildSuccessResponse(attProjectInsurance); } @ApiOperation(value = "承保信息列表(分页)") @GetMapping("/anze/underwriting/list") public BaseResponse> anzeUnderwritingList(@ApiParam(name = "attProjectInsuranceParam", value = "attProjectInsuranceParam", required = true) AttAnzeUnderwritingParam param) { Integer y = Optional.ofNullable(param.getYear()).orElse(Integer.parseInt(DateUtils.Date2Str(new Date(), "yyyy"))); param.setYear(y); param.setYear1(y); param.setYear2(y + 1); PageHelper.startPage(param); List list = attProjectInsuranceService.listOfUnderwriting(param); PageInfo pageInfo = new PageInfo<>(list); return buildSuccessResponse(pageInfo); } }