通过idea-mybatis-generator插件生成实体和mapper

通过该插件可以快速生成java代码, 能够支持读写分析

插件安装

首先打开插件市场

  • 使用command+shift+a, 输入plugins, 如下图所示
    在这里插入图片描述

搜索idea-mybatis-generator插件

  • 输入关键词idea-mybatis-generator
    在这里插入图片描述
  • 已经安装的就可以直接使用了
  • 如果本地没有安装该插件, 则点击图片红框中的按钮, 进行安装(安装完成需要重新启动idea)

插件使用

打开插件

  • 使用command+shift+a, 输入mybatis-generator, 如下图所示
    在这里插入图片描述

配置基本信息

  • 首次使用需要配置好数据库的基本信息
  • 配置完成后点击测试连接, 看是否成功
    在这里插入图片描述

配置基本信息

  1. 选择需要生成的表
  2. 选择生成后各文件的存放位置(entity, mapper, xml)
    在这里插入图片描述

生成内容

生成成功

  • 等待一会会出现成功的提示
    在这里插入图片描述

生成的entity

  • 这个插件生成的entity有个好处是自动将字段注释也生成了
  • 例如:
    /**
    * 主键
    * 
    * isNullAble:0
    */
    private Integer id;
  • 还会自动生成4的内部类, 用于查询, 修改等请求预计返回值的组装
    在这里插入图片描述

生成的mapper

  • 生成一个basemapper, 还有一个继承basemapper(默认里面是空的)
  • 如果选择读写分离则在分别生成一套read和一套write
public interface EvaluationRiskStatisticBaseMapper {

    int insertEvaluationRiskStatistic(EvaluationRiskStatistic object);

    int updateEvaluationRiskStatistic(EvaluationRiskStatistic object);

    int update(EvaluationRiskStatistic.UpdateBuilder object);

    List<EvaluationRiskStatistic> queryEvaluationRiskStatistic(EvaluationRiskStatistic object);

    EvaluationRiskStatistic queryEvaluationRiskStatisticLimit1(EvaluationRiskStatistic object);

}

生成的xml

  • xml生成也是想生成个base然后再生成个继承basexml(默认里面是空的)
  • 如果选择读写分离则在分别生成一套read和一套write
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wang.mapper.mysql.base.EvaluationRiskStatisticBaseMapper">


    <insert id="insertEvaluationRiskStatistic"  useGeneratedKeys="true" keyProperty="id">
        INSERT INTO `evaluation_risk_statistic`
        (
        <trim suffixOverrides=",">
                    <if test="id!=null">
                        `id`,
                    </if>
                    <if test="personId!=null">
                        `personId`,
                    </if>
                    <if test="gender!=null">
                        `gender`,
                    </if>
                    <if test="age!=null">
                        `age`,
                    </if>
                    <if test="bc!=null">
                        `bc`,
                    </if>
                    <if test="cvd!=null">
                        `cvd`,
                    </if>
                    <if test="depression!=null">
                        `depression`,
                    </if>
                    <if test="diab!=null">
                        `diab`,
                    </if>
                    <if test="dyslipidemia!=null">
                        `dyslipidemia`,
                    </if>
                    <if test="hbp!=null">
                        `hbp`,
                    </if>
                    <if test="lungcancer!=null">
                        `lungcancer`,
                    </if>
                    <if test="ms!=null">
                        `ms`,
                    </if>
                    <if test="obesity!=null">
                        `obesity`,
                    </if>
                    <if test="centralObesity!=null">
                        `central_obesity`,
                    </if>
                    <if test="op!=null">
                        `op`,
                    </if>
                    <if test="pc!=null">
                        `pc`,
                    </if>
                    <if test="sas!=null">
                        `sas`,
                    </if>
                    <if test="sportrisk!=null">
                        `sportrisk`,
                    </if>
                    <if test="stroke!=null">
                        `stroke`,
                    </if>
                    <if test="createTime!=null">
                        `create_time`,
                    </if>
        </trim>
        )
        VALUES
        (
        <trim suffixOverrides=",">
                <if test="id!=null">
                    #{id},
                </if>
                <if test="personId!=null">
                    #{personId},
                </if>
                <if test="gender!=null">
                    #{gender},
                </if>
                <if test="age!=null">
                    #{age},
                </if>
                <if test="bc!=null">
                    #{bc},
                </if>
                <if test="cvd!=null">
                    #{cvd},
                </if>
                <if test="depression!=null">
                    #{depression},
                </if>
                <if test="diab!=null">
                    #{diab},
                </if>
                <if test="dyslipidemia!=null">
                    #{dyslipidemia},
                </if>
                <if test="hbp!=null">
                    #{hbp},
                </if>
                <if test="lungcancer!=null">
                    #{lungcancer},
                </if>
                <if test="ms!=null">
                    #{ms},
                </if>
                <if test="obesity!=null">
                    #{obesity},
                </if>
                <if test="centralObesity!=null">
                    #{centralObesity},
                </if>
                <if test="op!=null">
                    #{op},
                </if>
                <if test="pc!=null">
                    #{pc},
                </if>
                <if test="sas!=null">
                    #{sas},
                </if>
                <if test="sportrisk!=null">
                    #{sportrisk},
                </if>
                <if test="stroke!=null">
                    #{stroke},
                </if>
                <if test="createTime!=null">
                    #{createTime},
                </if>
        </trim>
        )
    </insert>




    <update id="updateEvaluationRiskStatistic">
        UPDATE `evaluation_risk_statistic`
        SET
        <trim suffixOverrides=",">
            <if test="personId != null and personId!=''">
                `personId` = #{personId},
            </if>
            <if test="gender != null">
                `gender` = #{gender},
            </if>
            <if test="age != null">
                `age` = #{age},
            </if>
            <if test="bc != null">
                `bc` = #{bc},
            </if>
            <if test="cvd != null">
                `cvd` = #{cvd},
            </if>
            <if test="depression != null">
                `depression` = #{depression},
            </if>
            <if test="diab != null">
                `diab` = #{diab},
            </if>
            <if test="dyslipidemia != null">
                `dyslipidemia` = #{dyslipidemia},
            </if>
            <if test="hbp != null">
                `hbp` = #{hbp},
            </if>
            <if test="lungcancer != null">
                `lungcancer` = #{lungcancer},
            </if>
            <if test="ms != null">
                `ms` = #{ms},
            </if>
            <if test="obesity != null">
                `obesity` = #{obesity},
            </if>
            <if test="centralObesity != null">
                `central_obesity` = #{centralObesity},
            </if>
            <if test="op != null">
                `op` = #{op},
            </if>
            <if test="pc != null">
                `pc` = #{pc},
            </if>
            <if test="sas != null">
                `sas` = #{sas},
            </if>
            <if test="sportrisk != null">
                `sportrisk` = #{sportrisk},
            </if>
            <if test="stroke != null">
                `stroke` = #{stroke},
            </if>
            <if test="createTime != null">
                `create_time` = #{createTime},
            </if>
        </trim>
        WHERE
        <trim suffixOverrides="and">
                `id` = #{id} and
        </trim>
    </update>

    <update id="update">
        UPDATE `evaluation_risk_statistic`
        SET
        <trim suffixOverrides=",">
        <if test="set.personId != null and set.personId!=''">
            `personId` = #{set.personId},
        </if>
        <if test="set.gender != null">
            `gender` = #{set.gender},
        </if>
        <if test="set.age != null">
            `age` = #{set.age},
        </if>
        <if test="set.bc != null">
            `bc` = #{set.bc},
        </if>
        <if test="set.cvd != null">
            `cvd` = #{set.cvd},
        </if>
        <if test="set.depression != null">
            `depression` = #{set.depression},
        </if>
        <if test="set.diab != null">
            `diab` = #{set.diab},
        </if>
        <if test="set.dyslipidemia != null">
            `dyslipidemia` = #{set.dyslipidemia},
        </if>
        <if test="set.hbp != null">
            `hbp` = #{set.hbp},
        </if>
        <if test="set.lungcancer != null">
            `lungcancer` = #{set.lungcancer},
        </if>
        <if test="set.ms != null">
            `ms` = #{set.ms},
        </if>
        <if test="set.obesity != null">
            `obesity` = #{set.obesity},
        </if>
        <if test="set.centralObesity != null">
            `central_obesity` = #{set.centralObesity},
        </if>
        <if test="set.op != null">
            `op` = #{set.op},
        </if>
        <if test="set.pc != null">
            `pc` = #{set.pc},
        </if>
        <if test="set.sas != null">
            `sas` = #{set.sas},
        </if>
        <if test="set.sportrisk != null">
            `sportrisk` = #{set.sportrisk},
        </if>
        <if test="set.stroke != null">
            `stroke` = #{set.stroke},
        </if>
        <if test="set.createTime != null">
            `create_time` = #{set.createTime},
        </if>
        </trim>
        <trim prefix="where" suffixOverrides="and | or">
                <if test="where.idList != null">
                    `id` in
                    <foreach collection="where.idList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.idSt !=null">
                `id` >= #{where.idSt} and
            </if>
            <if test="where.idEd!=null">
                `id` &lt;= #{where.idEd} and
            </if>
                <if test="where.personIdList != null">
                    `personId` in
                    <foreach collection="where.personIdList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test ="where.fuzzyPersonId!=null and where.fuzzyPersonId.size()>0">
                (
                <foreach collection="where.fuzzyPersonId"  separator="or" item="item">
                    `PersonId` like concat('%',#{item},'%')
                </foreach>
                ) and
            </if>
            <if test ="where.rightFuzzyPersonId!=null and where.rightFuzzyPersonId.size()>0">
                (
                <foreach collection="where.rightFuzzyPersonId"  separator="or" item="item">
                    `PersonId` like concat(#{item},'%')
                </foreach>
                ) and
            </if>
                <if test="where.genderList != null">
                    `gender` in
                    <foreach collection="where.genderList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.genderSt !=null">
                `gender` >= #{where.genderSt} and
            </if>
            <if test="where.genderEd!=null">
                `gender` &lt;= #{where.genderEd} and
            </if>
                <if test="where.ageList != null">
                    `age` in
                    <foreach collection="where.ageList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.ageSt !=null">
                `age` >= #{where.ageSt} and
            </if>
            <if test="where.ageEd!=null">
                `age` &lt;= #{where.ageEd} and
            </if>
                <if test="where.bcList != null">
                    `bc` in
                    <foreach collection="where.bcList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.bcSt !=null">
                `bc` >= #{where.bcSt} and
            </if>
            <if test="where.bcEd!=null">
                `bc` &lt;= #{where.bcEd} and
            </if>
                <if test="where.cvdList != null">
                    `cvd` in
                    <foreach collection="where.cvdList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.cvdSt !=null">
                `cvd` >= #{where.cvdSt} and
            </if>
            <if test="where.cvdEd!=null">
                `cvd` &lt;= #{where.cvdEd} and
            </if>
                <if test="where.depressionList != null">
                    `depression` in
                    <foreach collection="where.depressionList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.depressionSt !=null">
                `depression` >= #{where.depressionSt} and
            </if>
            <if test="where.depressionEd!=null">
                `depression` &lt;= #{where.depressionEd} and
            </if>
                <if test="where.diabList != null">
                    `diab` in
                    <foreach collection="where.diabList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.diabSt !=null">
                `diab` >= #{where.diabSt} and
            </if>
            <if test="where.diabEd!=null">
                `diab` &lt;= #{where.diabEd} and
            </if>
                <if test="where.dyslipidemiaList != null">
                    `dyslipidemia` in
                    <foreach collection="where.dyslipidemiaList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.dyslipidemiaSt !=null">
                `dyslipidemia` >= #{where.dyslipidemiaSt} and
            </if>
            <if test="where.dyslipidemiaEd!=null">
                `dyslipidemia` &lt;= #{where.dyslipidemiaEd} and
            </if>
                <if test="where.hbpList != null">
                    `hbp` in
                    <foreach collection="where.hbpList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.hbpSt !=null">
                `hbp` >= #{where.hbpSt} and
            </if>
            <if test="where.hbpEd!=null">
                `hbp` &lt;= #{where.hbpEd} and
            </if>
                <if test="where.lungcancerList != null">
                    `lungcancer` in
                    <foreach collection="where.lungcancerList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.lungcancerSt !=null">
                `lungcancer` >= #{where.lungcancerSt} and
            </if>
            <if test="where.lungcancerEd!=null">
                `lungcancer` &lt;= #{where.lungcancerEd} and
            </if>
                <if test="where.msList != null">
                    `ms` in
                    <foreach collection="where.msList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.msSt !=null">
                `ms` >= #{where.msSt} and
            </if>
            <if test="where.msEd!=null">
                `ms` &lt;= #{where.msEd} and
            </if>
                <if test="where.obesityList != null">
                    `obesity` in
                    <foreach collection="where.obesityList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.obesitySt !=null">
                `obesity` >= #{where.obesitySt} and
            </if>
            <if test="where.obesityEd!=null">
                `obesity` &lt;= #{where.obesityEd} and
            </if>
                <if test="where.centralObesityList != null">
                    `central_obesity` in
                    <foreach collection="where.centralObesityList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.centralObesitySt !=null">
                `central_obesity` >= #{where.centralObesitySt} and
            </if>
            <if test="where.centralObesityEd!=null">
                `central_obesity` &lt;= #{where.centralObesityEd} and
            </if>
                <if test="where.opList != null">
                    `op` in
                    <foreach collection="where.opList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.opSt !=null">
                `op` >= #{where.opSt} and
            </if>
            <if test="where.opEd!=null">
                `op` &lt;= #{where.opEd} and
            </if>
                <if test="where.pcList != null">
                    `pc` in
                    <foreach collection="where.pcList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.pcSt !=null">
                `pc` >= #{where.pcSt} and
            </if>
            <if test="where.pcEd!=null">
                `pc` &lt;= #{where.pcEd} and
            </if>
                <if test="where.sasList != null">
                    `sas` in
                    <foreach collection="where.sasList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.sasSt !=null">
                `sas` >= #{where.sasSt} and
            </if>
            <if test="where.sasEd!=null">
                `sas` &lt;= #{where.sasEd} and
            </if>
                <if test="where.sportriskList != null">
                    `sportrisk` in
                    <foreach collection="where.sportriskList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.sportriskSt !=null">
                `sportrisk` >= #{where.sportriskSt} and
            </if>
            <if test="where.sportriskEd!=null">
                `sportrisk` &lt;= #{where.sportriskEd} and
            </if>
                <if test="where.strokeList != null">
                    `stroke` in
                    <foreach collection="where.strokeList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.strokeSt !=null">
                `stroke` >= #{where.strokeSt} and
            </if>
            <if test="where.strokeEd!=null">
                `stroke` &lt;= #{where.strokeEd} and
            </if>
                <if test="where.createTimeList != null">
                    `create_time` in
                    <foreach collection="where.createTimeList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
            <if test="where.createTimeSt !=null">
                `create_time` >= #{where.createTimeSt} and
            </if>
            <if test="where.createTimeEd!=null">
                `create_time` &lt;= #{where.createTimeEd} and
            </if>
        </trim>
    </update>


    <resultMap type="com.wang.entity.EvaluationRiskStatistic" id="EvaluationRiskStatisticMap">
        <result property="id" column="id"/>
        <result property="personId" column="personId"/>
        <result property="gender" column="gender"/>
        <result property="age" column="age"/>
        <result property="bc" column="bc"/>
        <result property="cvd" column="cvd"/>
        <result property="depression" column="depression"/>
        <result property="diab" column="diab"/>
        <result property="dyslipidemia" column="dyslipidemia"/>
        <result property="hbp" column="hbp"/>
        <result property="lungcancer" column="lungcancer"/>
        <result property="ms" column="ms"/>
        <result property="obesity" column="obesity"/>
        <result property="centralObesity" column="central_obesity"/>
        <result property="op" column="op"/>
        <result property="pc" column="pc"/>
        <result property="sas" column="sas"/>
        <result property="sportrisk" column="sportrisk"/>
        <result property="stroke" column="stroke"/>
        <result property="createTime" column="create_time"/>
    </resultMap>


    <select id="queryEvaluationRiskStatistic" resultMap="EvaluationRiskStatisticMap">
        select
        <include refid="baseResult"></include>
        from  `evaluation_risk_statistic`
        <trim prefix="where" suffixOverrides="and | or">
            <if test="id != null">
                `id` = #{id} and
            </if>
            <if test="personId != null and personId!=''">
                `personId` = #{personId} and
            </if>
            <if test="gender != null">
                `gender` = #{gender} and
            </if>
            <if test="age != null">
                `age` = #{age} and
            </if>
            <if test="bc != null">
                `bc` = #{bc} and
            </if>
            <if test="cvd != null">
                `cvd` = #{cvd} and
            </if>
            <if test="depression != null">
                `depression` = #{depression} and
            </if>
            <if test="diab != null">
                `diab` = #{diab} and
            </if>
            <if test="dyslipidemia != null">
                `dyslipidemia` = #{dyslipidemia} and
            </if>
            <if test="hbp != null">
                `hbp` = #{hbp} and
            </if>
            <if test="lungcancer != null">
                `lungcancer` = #{lungcancer} and
            </if>
            <if test="ms != null">
                `ms` = #{ms} and
            </if>
            <if test="obesity != null">
                `obesity` = #{obesity} and
            </if>
            <if test="centralObesity != null">
                `central_obesity` = #{centralObesity} and
            </if>
            <if test="op != null">
                `op` = #{op} and
            </if>
            <if test="pc != null">
                `pc` = #{pc} and
            </if>
            <if test="sas != null">
                `sas` = #{sas} and
            </if>
            <if test="sportrisk != null">
                `sportrisk` = #{sportrisk} and
            </if>
            <if test="stroke != null">
                `stroke` = #{stroke} and
            </if>
            <if test="createTime != null">
                `create_time` = #{createTime} and
            </if>
            <if test = "(_parameter instanceof com.wang.entity.EvaluationRiskStatistic$QueryBuilder) == true">
                <if test="idList != null">
                    `id` in
                    <foreach collection="idList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="idSt !=null">
                    `id` >= #{idSt} and
                </if>
                <if test="idEd!=null">
                    `id` &lt;= #{idEd} and
                </if>
                <if test="personIdList != null">
                    `personId` in
                    <foreach collection="personIdList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test ="fuzzyPersonId!=null and fuzzyPersonId.size()>0">
                    (
                    <foreach collection="fuzzyPersonId"  separator="or" item="item">
                        `PersonId` like concat('%',#{item},'%')
                    </foreach>
                    ) and
                </if>
                <if test ="rightFuzzyPersonId!=null and rightFuzzyPersonId.size()>0">
                    (
                    <foreach collection="rightFuzzyPersonId"  separator="or" item="item">
                        `PersonId` like concat(#{item},'%')
                    </foreach>
                    ) and
                </if>
                <if test="genderList != null">
                    `gender` in
                    <foreach collection="genderList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="genderSt !=null">
                    `gender` >= #{genderSt} and
                </if>
                <if test="genderEd!=null">
                    `gender` &lt;= #{genderEd} and
                </if>
                <if test="ageList != null">
                    `age` in
                    <foreach collection="ageList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="ageSt !=null">
                    `age` >= #{ageSt} and
                </if>
                <if test="ageEd!=null">
                    `age` &lt;= #{ageEd} and
                </if>
                <if test="bcList != null">
                    `bc` in
                    <foreach collection="bcList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="bcSt !=null">
                    `bc` >= #{bcSt} and
                </if>
                <if test="bcEd!=null">
                    `bc` &lt;= #{bcEd} and
                </if>
                <if test="cvdList != null">
                    `cvd` in
                    <foreach collection="cvdList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="cvdSt !=null">
                    `cvd` >= #{cvdSt} and
                </if>
                <if test="cvdEd!=null">
                    `cvd` &lt;= #{cvdEd} and
                </if>
                <if test="depressionList != null">
                    `depression` in
                    <foreach collection="depressionList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="depressionSt !=null">
                    `depression` >= #{depressionSt} and
                </if>
                <if test="depressionEd!=null">
                    `depression` &lt;= #{depressionEd} and
                </if>
                <if test="diabList != null">
                    `diab` in
                    <foreach collection="diabList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="diabSt !=null">
                    `diab` >= #{diabSt} and
                </if>
                <if test="diabEd!=null">
                    `diab` &lt;= #{diabEd} and
                </if>
                <if test="dyslipidemiaList != null">
                    `dyslipidemia` in
                    <foreach collection="dyslipidemiaList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="dyslipidemiaSt !=null">
                    `dyslipidemia` >= #{dyslipidemiaSt} and
                </if>
                <if test="dyslipidemiaEd!=null">
                    `dyslipidemia` &lt;= #{dyslipidemiaEd} and
                </if>
                <if test="hbpList != null">
                    `hbp` in
                    <foreach collection="hbpList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="hbpSt !=null">
                    `hbp` >= #{hbpSt} and
                </if>
                <if test="hbpEd!=null">
                    `hbp` &lt;= #{hbpEd} and
                </if>
                <if test="lungcancerList != null">
                    `lungcancer` in
                    <foreach collection="lungcancerList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="lungcancerSt !=null">
                    `lungcancer` >= #{lungcancerSt} and
                </if>
                <if test="lungcancerEd!=null">
                    `lungcancer` &lt;= #{lungcancerEd} and
                </if>
                <if test="msList != null">
                    `ms` in
                    <foreach collection="msList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="msSt !=null">
                    `ms` >= #{msSt} and
                </if>
                <if test="msEd!=null">
                    `ms` &lt;= #{msEd} and
                </if>
                <if test="obesityList != null">
                    `obesity` in
                    <foreach collection="obesityList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="obesitySt !=null">
                    `obesity` >= #{obesitySt} and
                </if>
                <if test="obesityEd!=null">
                    `obesity` &lt;= #{obesityEd} and
                </if>
                <if test="centralObesityList != null">
                    `central_obesity` in
                    <foreach collection="centralObesityList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="centralObesitySt !=null">
                    `central_obesity` >= #{centralObesitySt} and
                </if>
                <if test="centralObesityEd!=null">
                    `central_obesity` &lt;= #{centralObesityEd} and
                </if>
                <if test="opList != null">
                    `op` in
                    <foreach collection="opList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="opSt !=null">
                    `op` >= #{opSt} and
                </if>
                <if test="opEd!=null">
                    `op` &lt;= #{opEd} and
                </if>
                <if test="pcList != null">
                    `pc` in
                    <foreach collection="pcList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="pcSt !=null">
                    `pc` >= #{pcSt} and
                </if>
                <if test="pcEd!=null">
                    `pc` &lt;= #{pcEd} and
                </if>
                <if test="sasList != null">
                    `sas` in
                    <foreach collection="sasList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="sasSt !=null">
                    `sas` >= #{sasSt} and
                </if>
                <if test="sasEd!=null">
                    `sas` &lt;= #{sasEd} and
                </if>
                <if test="sportriskList != null">
                    `sportrisk` in
                    <foreach collection="sportriskList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="sportriskSt !=null">
                    `sportrisk` >= #{sportriskSt} and
                </if>
                <if test="sportriskEd!=null">
                    `sportrisk` &lt;= #{sportriskEd} and
                </if>
                <if test="strokeList != null">
                    `stroke` in
                    <foreach collection="strokeList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="strokeSt !=null">
                    `stroke` >= #{strokeSt} and
                </if>
                <if test="strokeEd!=null">
                    `stroke` &lt;= #{strokeEd} and
                </if>
                <if test="createTimeList != null">
                    `create_time` in
                    <foreach collection="createTimeList" close=")" open="(" separator="," item="item">
                        #{item}
                    </foreach> and
                </if>
                <if test="createTimeSt !=null">
                    `create_time` >= #{createTimeSt} and
                </if>
                <if test="createTimeEd!=null">
                    `create_time` &lt;= #{createTimeEd} and
                </if>
            </if>
        </trim>
    </select>

    <select id="queryEvaluationRiskStatisticLimit1" resultMap="EvaluationRiskStatisticMap">
        select
        <include refid="baseResult"></include>
        from  `evaluation_risk_statistic`
        <trim prefix="where" suffixOverrides="and | or">
            <if test="id != null">
                `id` = #{id} and
            </if>
            <if test="personId != null and personId!=''">
                `personId` = #{personId} and
            </if>
            <if test="gender != null">
                `gender` = #{gender} and
            </if>
            <if test="age != null">
                `age` = #{age} and
            </if>
            <if test="bc != null">
                `bc` = #{bc} and
            </if>
            <if test="cvd != null">
                `cvd` = #{cvd} and
            </if>
            <if test="depression != null">
                `depression` = #{depression} and
            </if>
            <if test="diab != null">
                `diab` = #{diab} and
            </if>
            <if test="dyslipidemia != null">
                `dyslipidemia` = #{dyslipidemia} and
            </if>
            <if test="hbp != null">
                `hbp` = #{hbp} and
            </if>
            <if test="lungcancer != null">
                `lungcancer` = #{lungcancer} and
            </if>
            <if test="ms != null">
                `ms` = #{ms} and
            </if>
            <if test="obesity != null">
                `obesity` = #{obesity} and
            </if>
            <if test="centralObesity != null">
                `central_obesity` = #{centralObesity} and
            </if>
            <if test="op != null">
                `op` = #{op} and
            </if>
            <if test="pc != null">
                `pc` = #{pc} and
            </if>
            <if test="sas != null">
                `sas` = #{sas} and
            </if>
            <if test="sportrisk != null">
                `sportrisk` = #{sportrisk} and
            </if>
            <if test="stroke != null">
                `stroke` = #{stroke} and
            </if>
            <if test="createTime != null">
                `create_time` = #{createTime} and
            </if>
            <if test = "(_parameter instanceof com.wang.entity.EvaluationRiskStatistic$QueryBuilder) == true">
                    <if test="idList != null">
                        `id` in
                        <foreach collection="idList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="idSt !=null">
                    `id` >= #{idSt} and
                </if>
                <if test="idEd!=null">
                    `id` &lt;= #{idEd} and
                </if>
                    <if test="personIdList != null">
                        `personId` in
                        <foreach collection="personIdList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test ="fuzzyPersonId!=null and fuzzyPersonId.size()>0">
                    (
                    <foreach collection="fuzzyPersonId"  separator="or" item="item">
                        `PersonId` like concat('%',#{item},'%')
                    </foreach>
                    ) and
                </if>
                <if test ="rightFuzzyPersonId!=null and rightFuzzyPersonId.size()>0">
                    (
                    <foreach collection="rightFuzzyPersonId"  separator="or" item="item">
                        `PersonId` like concat(#{item},'%')
                    </foreach>
                    ) and
                </if>
                    <if test="genderList != null">
                        `gender` in
                        <foreach collection="genderList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="genderSt !=null">
                    `gender` >= #{genderSt} and
                </if>
                <if test="genderEd!=null">
                    `gender` &lt;= #{genderEd} and
                </if>
                    <if test="ageList != null">
                        `age` in
                        <foreach collection="ageList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="ageSt !=null">
                    `age` >= #{ageSt} and
                </if>
                <if test="ageEd!=null">
                    `age` &lt;= #{ageEd} and
                </if>
                    <if test="bcList != null">
                        `bc` in
                        <foreach collection="bcList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="bcSt !=null">
                    `bc` >= #{bcSt} and
                </if>
                <if test="bcEd!=null">
                    `bc` &lt;= #{bcEd} and
                </if>
                    <if test="cvdList != null">
                        `cvd` in
                        <foreach collection="cvdList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="cvdSt !=null">
                    `cvd` >= #{cvdSt} and
                </if>
                <if test="cvdEd!=null">
                    `cvd` &lt;= #{cvdEd} and
                </if>
                    <if test="depressionList != null">
                        `depression` in
                        <foreach collection="depressionList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="depressionSt !=null">
                    `depression` >= #{depressionSt} and
                </if>
                <if test="depressionEd!=null">
                    `depression` &lt;= #{depressionEd} and
                </if>
                    <if test="diabList != null">
                        `diab` in
                        <foreach collection="diabList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="diabSt !=null">
                    `diab` >= #{diabSt} and
                </if>
                <if test="diabEd!=null">
                    `diab` &lt;= #{diabEd} and
                </if>
                    <if test="dyslipidemiaList != null">
                        `dyslipidemia` in
                        <foreach collection="dyslipidemiaList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="dyslipidemiaSt !=null">
                    `dyslipidemia` >= #{dyslipidemiaSt} and
                </if>
                <if test="dyslipidemiaEd!=null">
                    `dyslipidemia` &lt;= #{dyslipidemiaEd} and
                </if>
                    <if test="hbpList != null">
                        `hbp` in
                        <foreach collection="hbpList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="hbpSt !=null">
                    `hbp` >= #{hbpSt} and
                </if>
                <if test="hbpEd!=null">
                    `hbp` &lt;= #{hbpEd} and
                </if>
                    <if test="lungcancerList != null">
                        `lungcancer` in
                        <foreach collection="lungcancerList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="lungcancerSt !=null">
                    `lungcancer` >= #{lungcancerSt} and
                </if>
                <if test="lungcancerEd!=null">
                    `lungcancer` &lt;= #{lungcancerEd} and
                </if>
                    <if test="msList != null">
                        `ms` in
                        <foreach collection="msList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="msSt !=null">
                    `ms` >= #{msSt} and
                </if>
                <if test="msEd!=null">
                    `ms` &lt;= #{msEd} and
                </if>
                    <if test="obesityList != null">
                        `obesity` in
                        <foreach collection="obesityList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="obesitySt !=null">
                    `obesity` >= #{obesitySt} and
                </if>
                <if test="obesityEd!=null">
                    `obesity` &lt;= #{obesityEd} and
                </if>
                    <if test="centralObesityList != null">
                        `central_obesity` in
                        <foreach collection="centralObesityList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="centralObesitySt !=null">
                    `central_obesity` >= #{centralObesitySt} and
                </if>
                <if test="centralObesityEd!=null">
                    `central_obesity` &lt;= #{centralObesityEd} and
                </if>
                    <if test="opList != null">
                        `op` in
                        <foreach collection="opList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="opSt !=null">
                    `op` >= #{opSt} and
                </if>
                <if test="opEd!=null">
                    `op` &lt;= #{opEd} and
                </if>
                    <if test="pcList != null">
                        `pc` in
                        <foreach collection="pcList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="pcSt !=null">
                    `pc` >= #{pcSt} and
                </if>
                <if test="pcEd!=null">
                    `pc` &lt;= #{pcEd} and
                </if>
                    <if test="sasList != null">
                        `sas` in
                        <foreach collection="sasList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="sasSt !=null">
                    `sas` >= #{sasSt} and
                </if>
                <if test="sasEd!=null">
                    `sas` &lt;= #{sasEd} and
                </if>
                    <if test="sportriskList != null">
                        `sportrisk` in
                        <foreach collection="sportriskList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="sportriskSt !=null">
                    `sportrisk` >= #{sportriskSt} and
                </if>
                <if test="sportriskEd!=null">
                    `sportrisk` &lt;= #{sportriskEd} and
                </if>
                    <if test="strokeList != null">
                        `stroke` in
                        <foreach collection="strokeList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="strokeSt !=null">
                    `stroke` >= #{strokeSt} and
                </if>
                <if test="strokeEd!=null">
                    `stroke` &lt;= #{strokeEd} and
                </if>
                    <if test="createTimeList != null">
                        `create_time` in
                        <foreach collection="createTimeList" close=")" open="(" separator="," item="item">
                            #{item}
                        </foreach> and
                    </if>
                <if test="createTimeSt !=null">
                    `create_time` >= #{createTimeSt} and
                </if>
                <if test="createTimeEd!=null">
                    `create_time` &lt;= #{createTimeEd} and
                </if>
            </if>
        </trim>
        limit 1
    </select>

    <sql id="allResult">
        <trim suffixOverrides=",">
        `id`,
        `personId`,
        `gender`,
        `age`,
        `bc`,
        `cvd`,
        `depression`,
        `diab`,
        `dyslipidemia`,
        `hbp`,
        `lungcancer`,
        `ms`,
        `obesity`,
        `central_obesity`,
        `op`,
        `pc`,
        `sas`,
        `sportrisk`,
        `stroke`,
        `create_time`,
        </trim>
    </sql>



    <sql id="baseResult">
        <trim suffixOverrides=",">
            <if test = "(_parameter instanceof com.wang.entity.EvaluationRiskStatistic$QueryBuilder) == true">

                <if test="fetchFields==null">
                    <include refid="allResult"></include>
                </if>
                <if test="fetchFields!=null">
                    <if test="fetchFields.AllFields !=null">
                        <include refid="allResult"></include>
                    </if>
                    <if test="fetchFields.AllFields ==null and fetchFields.fetchFields==null and fetchFields.excludeFields==null and fetchFields.otherFields==null">
                        <include refid="allResult"></include>
                    </if>
                    <if test="fetchFields.AllFields==null and fetchFields.fetchFields!=null">
                    <if test="fetchFields.fetchFields.id==true">
                        `id`,
                    </if>
                    <if test="fetchFields.fetchFields.personId==true">
                        `personId`,
                    </if>
                    <if test="fetchFields.fetchFields.gender==true">
                        `gender`,
                    </if>
                    <if test="fetchFields.fetchFields.age==true">
                        `age`,
                    </if>
                    <if test="fetchFields.fetchFields.bc==true">
                        `bc`,
                    </if>
                    <if test="fetchFields.fetchFields.cvd==true">
                        `cvd`,
                    </if>
                    <if test="fetchFields.fetchFields.depression==true">
                        `depression`,
                    </if>
                    <if test="fetchFields.fetchFields.diab==true">
                        `diab`,
                    </if>
                    <if test="fetchFields.fetchFields.dyslipidemia==true">
                        `dyslipidemia`,
                    </if>
                    <if test="fetchFields.fetchFields.hbp==true">
                        `hbp`,
                    </if>
                    <if test="fetchFields.fetchFields.lungcancer==true">
                        `lungcancer`,
                    </if>
                    <if test="fetchFields.fetchFields.ms==true">
                        `ms`,
                    </if>
                    <if test="fetchFields.fetchFields.obesity==true">
                        `obesity`,
                    </if>
                    <if test="fetchFields.fetchFields.centralObesity==true">
                        `central_obesity`,
                    </if>
                    <if test="fetchFields.fetchFields.op==true">
                        `op`,
                    </if>
                    <if test="fetchFields.fetchFields.pc==true">
                        `pc`,
                    </if>
                    <if test="fetchFields.fetchFields.sas==true">
                        `sas`,
                    </if>
                    <if test="fetchFields.fetchFields.sportrisk==true">
                        `sportrisk`,
                    </if>
                    <if test="fetchFields.fetchFields.stroke==true">
                        `stroke`,
                    </if>
                    <if test="fetchFields.fetchFields.createTime==true">
                        `create_time`,
                    </if>
                    </if>
                    <if test="fetchFields.AllFields==null and fetchFields.excludeFields!=null">
                    <if test="fetchFields.excludeFields.id==null">
                        `id`,
                    </if>
                    <if test="fetchFields.excludeFields.personId==null">
                        `personId`,
                    </if>
                    <if test="fetchFields.excludeFields.gender==null">
                        `gender`,
                    </if>
                    <if test="fetchFields.excludeFields.age==null">
                        `age`,
                    </if>
                    <if test="fetchFields.excludeFields.bc==null">
                        `bc`,
                    </if>
                    <if test="fetchFields.excludeFields.cvd==null">
                        `cvd`,
                    </if>
                    <if test="fetchFields.excludeFields.depression==null">
                        `depression`,
                    </if>
                    <if test="fetchFields.excludeFields.diab==null">
                        `diab`,
                    </if>
                    <if test="fetchFields.excludeFields.dyslipidemia==null">
                        `dyslipidemia`,
                    </if>
                    <if test="fetchFields.excludeFields.hbp==null">
                        `hbp`,
                    </if>
                    <if test="fetchFields.excludeFields.lungcancer==null">
                        `lungcancer`,
                    </if>
                    <if test="fetchFields.excludeFields.ms==null">
                        `ms`,
                    </if>
                    <if test="fetchFields.excludeFields.obesity==null">
                        `obesity`,
                    </if>
                    <if test="fetchFields.excludeFields.centralObesity==null">
                        `central_obesity`,
                    </if>
                    <if test="fetchFields.excludeFields.op==null">
                        `op`,
                    </if>
                    <if test="fetchFields.excludeFields.pc==null">
                        `pc`,
                    </if>
                    <if test="fetchFields.excludeFields.sas==null">
                        `sas`,
                    </if>
                    <if test="fetchFields.excludeFields.sportrisk==null">
                        `sportrisk`,
                    </if>
                    <if test="fetchFields.excludeFields.stroke==null">
                        `stroke`,
                    </if>
                    <if test="fetchFields.excludeFields.createTime==null">
                        `create_time`,
                    </if>
                    </if>
                    <if test="fetchFields.otherFields!=null and fetchFields.otherFields.size>0">
                        <foreach collection="fetchFields.otherFields" index="index" item="item" separator=",">
                        `#{item}`
                        </foreach>
                    </if>
                </if>
            </if>
            <if test="(_parameter instanceof com.wang.entity.EvaluationRiskStatistic$QueryBuilder) == false" >
                <include refid="allResult"></include>
            </if>

        </trim>
    </sql>


</mapper>
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值