Commit 32926db2 authored by 李灿灿's avatar 李灿灿

feat:保单号对应起止保时间接口完善

parent 5bc7c1e3
package com.yifu.cloud.plus.v1.yifu.insurances.vo;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TBusinessOperate;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsurancePolicy;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
/**
* @author licancan
* @description 保单号对应起止时间详情vo
* @date 2022-12-08 11:11:35
*/
@Data
@Schema(description = "保单号对应起止时间详情vo")
public class TInsurancePolicyDetailVO extends TInsurancePolicy {
/**
* 操作记录列表
*/
@Schema(description = "操作记录列表")
List<TBusinessOperate> operateList;
}
......@@ -3,12 +3,11 @@ package com.yifu.cloud.plus.v1.yifu.insurances.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceCompany;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsurancePolicy;
import com.yifu.cloud.plus.v1.yifu.insurances.service.insurance.TInsurancePolicyService;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsurancePolicyListEditParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsurancePolicyListParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.TInsurancePolicyDetailVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
......@@ -61,16 +60,16 @@ public class TInsurancePolicyController {
}
/**
* 通过id查询详情 todo 加操作日志,先给前端后续再补
* 通过id查询详情
*
* @author licancan
* @param id
* @return {@link R<TInsurancePolicy>}
* @return {@link R<TInsurancePolicyDetailVO>}
*/
@GetMapping("/{id}")
@Operation(summary = "通过id查询详情", description = "通过id查询详情")
public R<TInsurancePolicy> getById(@PathVariable("id" ) String id) {
return R.ok(tInsurancePolicyService.getById(id));
public R<TInsurancePolicyDetailVO> getDetailById(@PathVariable("id" ) String id) {
return tInsurancePolicyService.getDetailById(id);
}
/**
......
......@@ -7,6 +7,7 @@ import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsurancePolicy;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsurancePolicyListEditParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsurancePolicyListParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.TInsurancePolicyDetailVO;
import java.util.List;
......@@ -36,6 +37,24 @@ public interface TInsurancePolicyService extends IService<TInsurancePolicy> {
*/
List<TInsurancePolicy> getInsurancePolicyList(InsurancePolicyListParam param);
/**
* 通过id查询详情
*
* @author licancan
* @param id
* @return {@link R<TInsurancePolicyDetailVO>}
*/
R<TInsurancePolicyDetailVO> getDetailById(String id);
/**
* 新增
*
* @author licancan
* @param policy
* @return {@link R}
*/
R saveTInsurancePolicy(TInsurancePolicy policy);
/**
* 修改保单号对应起止保时间
*
......
......@@ -2,22 +2,29 @@ package com.yifu.cloud.plus.v1.yifu.insurances.service.insurance.impl;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TBusinessOperate;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsurancePolicy;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceTypeRate;
import com.yifu.cloud.plus.v1.yifu.insurances.mapper.insurances.TInsurancePolicyMapper;
import com.yifu.cloud.plus.v1.yifu.insurances.service.insurance.TBusinessOperateService;
import com.yifu.cloud.plus.v1.yifu.insurances.service.insurance.TInsuranceDetailService;
import com.yifu.cloud.plus.v1.yifu.insurances.service.insurance.TInsurancePolicyService;
import com.yifu.cloud.plus.v1.yifu.insurances.util.BeanCopyUtils;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsurancePolicyListEditParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsurancePolicyListParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.TInsurancePolicyDetailVO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;
......@@ -29,6 +36,10 @@ import java.util.Optional;
*/
@Service
public class TInsurancePolicyServiceImpl extends ServiceImpl<TInsurancePolicyMapper, TInsurancePolicy> implements TInsurancePolicyService {
@Resource
private TBusinessOperateService tBusinessOperateService;
@Resource
private TInsuranceDetailService tInsuranceDetailService;
/**
* 保单号对应起止保时间分页查询
......@@ -57,6 +68,52 @@ public class TInsurancePolicyServiceImpl extends ServiceImpl<TInsurancePolicyMap
return list;
}
/**
* 通过id查询详情
*
* @param id
* @return {@link R<TInsurancePolicyDetailVO>}
* @author licancan
*/
@Override
public R<TInsurancePolicyDetailVO> getDetailById(String id) {
if(Common.isEmpty(id)){
return R.failed("id不能为空");
}
TInsurancePolicy byId = getById(id);
if (!Optional.ofNullable(byId).isPresent()){
return R.failed("数据不存在");
}
TInsurancePolicyDetailVO vo = new TInsurancePolicyDetailVO();
BeanCopyUtils.copyProperties(byId,vo);
List<TBusinessOperate> list = tBusinessOperateService.getOperateListByBusinessId(id);
if (CollectionUtils.isNotEmpty(list)){
vo.setOperateList(list);
}
return R.ok(vo);
}
/**
* 新增,内部调用的,保证调用方把该传的字段都传了(保单号、起止保时间、保险公司、险种)
*
* @param policy
* @return {@link R}
* @author licancan
*/
@Override
public R saveTInsurancePolicy(TInsurancePolicy policy) {
if (StringUtils.isNotEmpty(policy.getPolicyNo())){
TInsurancePolicy one = this.getOne(Wrappers.<TInsurancePolicy>query().lambda()
.eq(TInsurancePolicy::getPolicyNo, policy.getPolicyNo())
.eq(TInsurancePolicy::getDeleteFlag,CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL));
if (!Optional.ofNullable(one).isPresent()){
this.save(policy);
}
}
return R.ok();
}
/**
* 修改保单号对应起止保时间
*
......@@ -73,7 +130,8 @@ public class TInsurancePolicyServiceImpl extends ServiceImpl<TInsurancePolicyMap
}
BeanCopyUtils.copyProperties(param,tInsurancePolicy);
updateById(tInsurancePolicy);
//todo 操作日志
//操作日志
tBusinessOperateService.saveModificationRecord(param.getId(),tInsurancePolicy,param,null);
return R.ok();
}
......@@ -93,7 +151,14 @@ public class TInsurancePolicyServiceImpl extends ServiceImpl<TInsurancePolicyMap
if (!Optional.ofNullable(byId).isPresent()){
return R.failed("数据不存在");
}
//todo 检验保单号是否被使用,被使用不能删除
//检验保单号是否被使用,被使用不能删除
TInsuranceDetail one = tInsuranceDetailService.getOne(Wrappers.<TInsuranceDetail>query().lambda()
.eq(TInsuranceDetail::getPolicyNo, byId.getPolicyNo())
.eq(TInsuranceDetail::getDeleteFlag,CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL));
if (Optional.ofNullable(one).isPresent()){
return R.failed("存在正常关联的承保信息,禁止删除!");
}
LambdaUpdateWrapper<TInsurancePolicy> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(TInsurancePolicy::getId,id)
.set(TInsurancePolicy::getDeleteFlag, CommonConstants.ONE_INT);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment