Commit c6215801 authored by 李灿灿's avatar 李灿灿

feat:保单号对应起止保时间基础代码

parent c396a2e5
package com.yifu.cloud.plus.v1.yifu.insurances.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDate;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @author licancan
* @description 保单号对应起止时间表 t_insurance_policy
* @date 2022-12-07 16:40:16
*/
@Schema(description = "保单号对应起止时间表")
@Data
public class TInsurancePolicy extends BaseEntity {
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private String id;
/**
* 保单编号
*/
@Schema(description = "保单编号")
private String policyNo;
/**
* 保单开始时间
*/
@Schema(description = "保单开始时间")
private LocalDate policyStart;
/**
* 保单结束时间
*/
@Schema(description = "保单结束时间")
private LocalDate policyEnd;
/**
* 保险公司名称
*/
@Schema(description = "保险公司名称")
private String insuranceCompanyName;
/**
* 险种名称
*/
@Schema(description = "险种名称")
private String insuranceTypeName;
/**
* 是否启用标识 0启用 1未启用
*/
@Schema(description = "是否启用标识 0启用 1未启用")
private Integer enableFlag;
/**
* 是否删除 0未删除 1删除
*/
@Schema(description = "是否删除 0未删除 1删除")
private Integer deleteFlag;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package com.yifu.cloud.plus.v1.yifu.insurances.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.checkerframework.common.value.qual.IntVal;
import org.checkerframework.common.value.qual.StringVal;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDate;
/**
* @author licancan
* @description 保单对应起止保时间编辑入参
* @date 2022-12-07 17:39:45
*/
@Data
@Schema(description = "保单对应起止保时间编辑入参")
public class InsurancePolicyListEditParam implements Serializable {
private static final long serialVersionUID = 9200033608149413253L;
/**
* 主键
*/
@Schema(description = "主键")
@NotBlank(message = "主键不能为空")
private String id;
/**
* 保单编号
*/
@Schema(description = "保单编号")
@NotBlank(message = "保单编号不能为空")
private String policyNo;
/**
* 保单开始时间
*/
@Schema(description = "保单开始时间")
@NotBlank(message = "保单开始时间不能为空")
private String policyStart;
/**
* 保单结束时间
*/
@Schema(description = "保单结束时间")
@NotBlank(message = "保单结束时间不能为空")
private String policyEnd;
/**
* 保险公司名称
*/
@Schema(description = "保险公司名称")
@NotBlank(message = "保险公司名称不能为空")
private String insuranceCompanyName;
/**
* 险种名称
*/
@Schema(description = "险种名称")
@NotBlank(message = "险种名称不能为空")
private String insuranceTypeName;
/**
* 是否启用标识 0启用 1未启用
*/
@Schema(description = "是否启用标识 0启用 1未启用")
@NotNull(message = "启用标识不能为空")
@IntVal({0,1})
private Integer enableFlag;
}
package com.yifu.cloud.plus.v1.yifu.insurances.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* @author licancan
* @description 保单对应起止保时间列表入参
* @date 2022-12-07 17:12:27
*/
@Data
@Schema(description = "保单对应起止保时间列表入参")
public class InsurancePolicyListParam implements Serializable {
private static final long serialVersionUID = 1442112261102562729L;
/**
* 保单编号
*/
@Schema(description = "保单编号")
private String policyNo;
/**
* 保单开始时间
*/
@Schema(description = "保单开始时间")
private String policyStart;
/**
* 保单结束时间
*/
@Schema(description = "保单结束时间")
private String policyEnd;
/**
* 保险公司名称
*/
@Schema(description = "保险公司名称")
private String insuranceCompanyName;
/**
* 险种名称
*/
@Schema(description = "险种名称")
private String insuranceTypeName;
/**
* 是否启用标识 0启用 1未启用
*/
@Schema(description = "是否启用标识 0启用 1未启用")
private Integer enableFlag;
}
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 io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* @author licancan
* @description 保单号对应起止保时间 controller
* @date 2022-12-07 16:56:53
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/insurancePolicy")
@Tag(name = "保单号对应起止保时间相关")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class TInsurancePolicyController {
@Resource
private TInsurancePolicyService tInsurancePolicyService;
/**
* 保单号对应起止保时间分页查询
*
* @author licancan
* @param page 分页对象
* @param param 查询参数
* @return {@link R<IPage<TInsurancePolicy>>}
*/
@Operation(summary = "保单号对应起止保时间分页查询", description = "保单号对应起止保时间分页查询")
@GetMapping("/page" )
public R<IPage<TInsurancePolicy>> getInsurancePolicyPage(Page page, InsurancePolicyListParam param) {
return R.ok(tInsurancePolicyService.pageDiy(page, param));
}
/**
* 保单号对应起止保时间列表(不分页)
*
* @author licancan
* @param param
* @return {@link R<List<TInsurancePolicy>>}
*/
@Operation(summary = "保单号对应起止保时间列表(不分页)", description = "保单号对应起止保时间(不分页)")
@GetMapping("/list")
public R<List<TInsurancePolicy>> getInsurancePolicyList(InsurancePolicyListParam param) {
return R.ok(tInsurancePolicyService.getInsurancePolicyList(param));
}
/**
* 通过id查询详情 todo 加操作日志,先给前端后续再补
*
* @author licancan
* @param id
* @return {@link R<TInsurancePolicy>}
*/
@GetMapping("/{id}")
@Operation(summary = "通过id查询详情", description = "通过id查询详情")
public R<TInsurancePolicy> getById(@PathVariable("id" ) String id) {
return R.ok(tInsurancePolicyService.getById(id));
}
/**
* 修改保单号对应起止保时间
*
* @author licancan
* @param param 修改参数
* @return {@link R}
*/
@Operation(summary = "修改保单号对应起止保时间", description = "修改保单号对应起止保时间)")
@PostMapping("/update")
public R update(@RequestBody InsurancePolicyListEditParam param) {
return tInsurancePolicyService.updateInsurancePolicy(param);
}
/**
* 删除保单号对应起止保时间
*
* @author licancan
* @param id 主键
* @return {@link R}
*/
@Operation(summary = "删除保单号对应起止保时间", description = "删除保单号对应起止保时间")
@DeleteMapping("/{id}" )
public R deleteById(@PathVariable("id") String id) {
return tInsurancePolicyService.deleteInsurancePolicy(id);
}
}
package com.yifu.cloud.plus.v1.yifu.insurances.mapper.insurances;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsurancePolicy;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsurancePolicyListParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author licancan
* @description 针对表【t_insurance_policy(保单号对应起止时间表)】的数据库操作Mapper
* @date 2022-12-07 16:40:16
*/
@Mapper
public interface TInsurancePolicyMapper extends BaseMapper<TInsurancePolicy> {
/**
* 保单号对应起止保时间分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return {@link IPage <TInsurancePolicy>}
* @author licancan
*/
IPage<TInsurancePolicy> getInsurancePolicyListPage(Page page,@Param("param") InsurancePolicyListParam param);
/**
* 保单号对应起止保时间列表(不分页)
*
* @author licancan
* @param param
* @return {@link List< TInsurancePolicy>}
*/
List<TInsurancePolicy> getInsurancePolicyList(@Param("param") InsurancePolicyListParam param);
}
package com.yifu.cloud.plus.v1.yifu.insurances.service.insurance;
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.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 java.util.List;
/**
* @author licancan
* @description 针对表【t_insurance_policy(保单号对应起止时间表)】的数据库操作Service
* @date 2022-12-07 16:40:16
*/
public interface TInsurancePolicyService extends IService<TInsurancePolicy> {
/**
* 保单号对应起止保时间分页查询
*
* @author licancan
* @param page 分页对象
* @param param 查询参数
* @return {@link IPage<TInsurancePolicy>}
*/
IPage<TInsurancePolicy> pageDiy(Page page, InsurancePolicyListParam param);
/**
* 保单号对应起止保时间列表(不分页)
*
* @author licancan
* @param param
* @return {@link List<TInsurancePolicy>}
*/
List<TInsurancePolicy> getInsurancePolicyList(InsurancePolicyListParam param);
/**
* 修改保单号对应起止保时间
*
* @author licancan
* @param param
* @return {@link R}
*/
R updateInsurancePolicy(InsurancePolicyListEditParam param);
/**
* 删除保单号对应起止保时间
*
* @author licancan
* @param id 主键
* @return {@link R}
*/
R deleteInsurancePolicy(String id);
}
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.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.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.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 org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
/**
* @author licancan
* @description 针对表【t_insurance_policy(保单号对应起止时间表)】的数据库操作Service实现
* @date 2022-12-07 16:40:16
*/
@Service
public class TInsurancePolicyServiceImpl extends ServiceImpl<TInsurancePolicyMapper, TInsurancePolicy> implements TInsurancePolicyService {
/**
* 保单号对应起止保时间分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return {@link IPage <TInsurancePolicy>}
* @author licancan
*/
@Override
public IPage<TInsurancePolicy> pageDiy(Page page, InsurancePolicyListParam param) {
IPage<TInsurancePolicy> list = this.baseMapper.getInsurancePolicyListPage(page, param);
return list;
}
/**
* 保单号对应起止保时间列表(不分页)
*
* @param param
* @return {@link List<TInsurancePolicy>}
* @author licancan
*/
@Override
public List<TInsurancePolicy> getInsurancePolicyList(InsurancePolicyListParam param) {
List<TInsurancePolicy> list = this.baseMapper.getInsurancePolicyList(param);
return list;
}
/**
* 修改保单号对应起止保时间
*
* @param param
* @return {@link R}
* @author licancan
*/
@Override
@Transactional(value = "insurancesTransactionManager" ,rollbackFor = {Exception.class})
public R updateInsurancePolicy(InsurancePolicyListEditParam param) {
TInsurancePolicy tInsurancePolicy = this.baseMapper.selectById(param.getId());
if (!Optional.ofNullable(tInsurancePolicy).isPresent()){
return R.failed("数据不存在");
}
BeanCopyUtils.copyProperties(param,tInsurancePolicy);
updateById(tInsurancePolicy);
//todo 操作日志
return R.ok();
}
/**
* 删除保单号对应起止保时间
*
* @param id 主键
* @return {@link R}
* @author licancan
*/
@Override
public R deleteInsurancePolicy(String id) {
if(Common.isEmpty(id)){
return R.failed("id不能为空");
}
TInsurancePolicy byId = getById(id);
if (!Optional.ofNullable(byId).isPresent()){
return R.failed("数据不存在");
}
//todo 检验保单号是否被使用,被使用不能删除
LambdaUpdateWrapper<TInsurancePolicy> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(TInsurancePolicy::getId,id)
.set(TInsurancePolicy::getDeleteFlag, CommonConstants.ONE_INT);
update(updateWrapper);
return R.ok();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.insurances.mapper.insurances.TInsurancePolicyMapper">
<resultMap id="BaseResultMap" type="com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsurancePolicy">
<id property="id" column="ID" jdbcType="VARCHAR"/>
<result property="policyNo" column="POLICY_NO" jdbcType="VARCHAR"/>
<result property="policyStart" column="POLICY_START" jdbcType="DATE"/>
<result property="policyEnd" column="POLICY_END" jdbcType="DATE"/>
<result property="insuranceCompanyName" column="INSURANCE_COMPANY_NAME" jdbcType="VARCHAR"/>
<result property="insuranceTypeName" column="INSURANCE_TYPE_NAME" jdbcType="VARCHAR"/>
<result property="enableFlag" column="ENABLE_FLAG" jdbcType="TINYINT"/>
<result property="deleteFlag" column="DELETE_FLAG" jdbcType="TINYINT"/>
<result property="createBy" column="CREATE_BY" jdbcType="VARCHAR"/>
<result property="createName" column="CREATE_NAME" jdbcType="VARCHAR"/>
<result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="UPDATE_BY" jdbcType="VARCHAR"/>
<result property="updateTime" column="UPDATE_TIME" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
ID,POLICY_NO,POLICY_START,
POLICY_END,INSURANCE_COMPANY_NAME,INSURANCE_TYPE_NAME,
ENABLE_FLAG,DELETE_FLAG,CREATE_BY,
CREATE_NAME,CREATE_TIME,UPDATE_BY,
UPDATE_TIME
</sql>
<select id="getInsurancePolicyListPage" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"></include>
FROM t_insurance_policy
where DELETE_FLAG = 0
<if test="param.policyNo != null and param.policyNo.trim() != ''">
and POLICY_NO like concat('%',replace(replace(#{param.policyNo},'_','\_'),'%','\%'),'%')
</if>
<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd == null and param.policyEnd.trim() == ''">
AND POLICY_END <![CDATA[ >= ]]> #{param.policyStart}
</if>
<if test="param.policyEnd != null and param.policyEnd.trim() != '' and param.policyStart == null and param.policyStart.trim() == ''">
AND POLICY_START <![CDATA[ <= ]]> #{param.policyEnd}
</if>
<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
and INSURANCE_COMPANY_NAME like concat('%',replace(replace(#{param.insuranceCompanyName},'_','\_'),'%','\%'),'%')
</if>
<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
and INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
</if>
<if test="param.enableFlag != null">
and ENABLE_FLAG = #{enableFlag}
</if>
ORDER BY CREATE_TIME DESC
</select>
<select id="getInsurancePolicyList" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"></include>
FROM t_insurance_policy
where DELETE_FLAG = 0
<if test="param.policyNo != null and param.policyNo.trim() != ''">
and POLICY_NO like concat('%',replace(replace(#{param.policyNo},'_','\_'),'%','\%'),'%')
</if>
<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd == null and param.policyEnd.trim() == ''">
AND POLICY_END <![CDATA[ >= ]]> #{param.policyStart}
</if>
<if test="param.policyEnd != null and param.policyEnd.trim() != '' and param.policyStart == null and param.policyStart.trim() == ''">
AND POLICY_START <![CDATA[ <= ]]> #{param.policyEnd}
</if>
<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
and INSURANCE_COMPANY_NAME like concat('%',replace(replace(#{param.insuranceCompanyName},'_','\_'),'%','\%'),'%')
</if>
<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
and INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
</if>
<if test="param.enableFlag != null">
and ENABLE_FLAG = #{enableFlag}
</if>
ORDER BY CREATE_TIME DESC
</select>
</mapper>
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