Commit dc9add1d by 翁国栋 Committed by 284718418@qq.com

8小时后台--

投保需求变更,需要在被保险人信息组增加省市区
parent a8485e19
package cn.timer.api.bean.insure;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
* 省市区
*
* @author wgd
* @email 862422848@qq.com
* @date 2022-06-27 15:09:26
*/
@Entity
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "insure_province")
@ApiModel("省市区")
public class InsureProvince extends Model<InsureProvince> {
private static final long serialVersionUID = 4347130709431957277L;
@Id
private Integer id;
/**
* 名字
*/
private String name;
/**
* 值
*/
private Integer pid;
/**
* 值
*/
private Integer value;
}
package cn.timer.api.controller.insure;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.timer.api.bean.insure.InsureApplicant;
import cn.timer.api.bean.insure.InsureProvince;
import cn.timer.api.bean.qyzx.QyzxEntInfoM;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
......@@ -93,7 +98,6 @@ public class InsureApplicantController {
insureApplicant.setApplicantType("2");
insureApplicant.setApplicantENoType("3646");
insureApplicant.setApplicantENo(qyzxEntInfoM.getCreditCode());
insureApplicant.setApplicantProvinceCity("21721");
return insureApplicant;
}
......@@ -115,5 +119,27 @@ public class InsureApplicantController {
throw new CustomException("获取投保人异常");
}
}
@GetMapping("/getProvince")
@ApiOperation(value = "获取投保省市区", httpMethod = "GET", notes = "获取投保人")
@Transactional(rollbackFor = Exception.class)
public Result<Object> getRegion(){
List<InsureProvince> nodeList= InsureProvince.builder().build().selectList(new QueryWrapper<InsureProvince>().lambda().isNotNull(InsureProvince::getId));
// 配置
TreeNodeConfig treeNodeConfig = new TreeNodeConfig();
// 自定义属性名 都要默认值的
treeNodeConfig.setIdKey("id");
treeNodeConfig.setParentIdKey("parentId");
// 最大递归深度
treeNodeConfig.setDeep(4);
List<Tree<String>> treeNodes = TreeUtil.build(nodeList, "0", treeNodeConfig, (treeNode, tree) -> {
tree.setId(treeNode.getId().toString());
tree.setParentId(treeNode.getPid().toString());
tree.setName(treeNode.getName());
tree.putExtra("value", treeNode.getValue());
});
return ResultUtil.data(treeNodes);
}
}
package cn.timer.api.dao.insure;
import cn.timer.api.bean.insure.InsureProvince;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
/**
* 省市区
*
* @author wgd
* @email 862422848@qq.com
* @date 2022-06-27 15:09:26
*/
@Repository
public interface InsureProvinceMapper extends BaseMapper<InsureProvince> {
}
<?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="cn.timer.api.dao.insure.InsureProvinceMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="cn.timer.api.bean.insure.InsureProvince" id="insureProvinceMap">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="pid" column="pid"/>
<result property="value" column="value"/>
</resultMap>
<select id="queryObject" resultType="cn.timer.api.bean.insure.InsureProvince">
select *
from insure_province
where id = #{value}
</select>
<select id="queryList" resultType="cn.timer.api.bean.insure.InsureProvince">
select * from insure_province
<where>
<if test="name != null and name != ''">AND `name` = #{name}</if>
<if test="pid != null and pid != ''">AND `pid` = #{pid}</if>
<if test="value != null and value != ''">AND `value` = #{value}</if>
</where>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="queryTotal" resultType="int">
select count(*) from insure_province
<where>
<if test="name != null and name != ''">AND `name` = #{name}</if>
<if test="pid != null and pid != ''">AND `pid` = #{pid}</if>
<if test="value != null and value != ''">AND `value` = #{value}</if>
</where>
</select>
<insert id="save" parameterType="cn.timer.api.bean.insure.InsureProvince" useGeneratedKeys="true" keyProperty="id">
insert into insure_province
(`name`,
`pid`,
`value`)
values (#{name},
#{pid},
#{value})
</insert>
<insert id="saveSelective" parameterType="cn.timer.api.bean.insure.InsureProvince" useGeneratedKeys="true"
keyProperty="id">
insert into insure_province
(
<if test="name != null">,`name`</if>
<if test="pid != null">,`pid`</if>
<if test="value != null">,`value`</if>
)
values
(
<if test="name != null">,#{name}</if>
<if test="pid != null">,#{pid}</if>
<if test="value != null">,#{value}</if>
)
</insert>
<insert id="saveList" parameterType="cn.timer.api.bean.insure.InsureProvince" useGeneratedKeys="true"
keyProperty="id">
insert into insure_province
(
`name`,
`pid`,
`value`
)
values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.name},
#{item.pid},
#{item.value}
)
</foreach>
</insert>
<update id="update" parameterType="cn.timer.api.bean.insure.InsureProvince">
update insure_province
<set>
<if test="name != null">`name` = #{name},</if>
<if test="pid != null">`pid` = #{pid},</if>
<if test="value != null">`value` = #{value}</if>
</set>
where id = #{id}
</update>
<delete id="delete">
delete
from insure_province
where id = #{value}
</delete>
<delete id="deleteBatch">
delete from insure_province where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</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