<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.error.dao.ibatis.ErrorLogDaoImpl">

    <!-- 字段和属性映射 -->
    <resultMap type="ErrorLogEntity" id="ErrorLogEntity-Map">
        <id  property="id" column="id" />
        <result property="traceID" column="traceID" />
        <result property="appName" column="appName" />
        <result property="hostName" column="hostName" />
        <result property="message" column="message" />
        <result property="platform" column="platform" />
        <result property="culprit" column="culprit" />
        <result property="tags" column="tags" />
        <result property="level" column="level" />
        <result property="environment" column="environment" />
        <result property="releaseVersion" column="releaseVersion" />
        <result property="fingerprint" column="fingerprint" />
        <result property="threadNo" column="threadNo" />
        <result property="checkNum" column="checkNum" />
        <result property="errorStack" column="errorStack" />
        <result property="context" column="context" />
        <result property="extra" column="extra" />
        <result property="logTime" column="logTime" />
        <result property="createUserId" column="createUserId" />
        <result property="createTime" column="createTime" />
        <result property="updateTime" column="updateTime" />

    </resultMap>

    <update id="createTable" parameterType="paramDto">
        CREATE TABLE `${tableName}`(
        `id` bigint(20)     COMMENT '主键ID',
        `traceID` varchar(64)     COMMENT '追踪Id',
        `appName` varchar(64)     COMMENT '应用名称，宿主客户端运行唯一标识。',
        `hostName` varchar(64)     COMMENT '主机名',
        `message` varchar(1024)     COMMENT '消息标识，如用户登录异常。',
        `platform` varchar(64)     COMMENT '当前客户端使用平台(java,php,c#,android,vue,webos,ios,python)',
        `culprit` varchar(2048)     COMMENT '主要导致异常函数或方法调用名称及入参',
        `tags` varchar(256)     COMMENT '异常事件标记，多个逗号分隔。用以归集异常事件种类。',
        `level` varchar(64)     COMMENT '等级(FATAL，ERROR,WARNING,INFO,DEBUG)',
        `environment` varchar(1024)     COMMENT '客户端运行环境变量信息',
        `releaseVersion` varchar(64)     COMMENT '客户端运行版本信息',
        `fingerprint` varchar(64)     COMMENT '指纹标识，对于相同异常事件归集数量使用。',
        `threadNo` varchar(1024)     COMMENT '线程号',
        `checkNum` int(4)     COMMENT '针对同一个异常事件，数量加1',
        `errorStack` text     COMMENT '异常堆栈信息',
        `context` text     COMMENT '上下文信息，如js中发送异常事件，定位源码中信息。',
        `extra` varchar(2048)     COMMENT '扩展信息',
        `logTime` datetime     COMMENT '日志时间',
        `createUserId` bigint(20)     COMMENT '创建用户',
        `createTime` datetime NOT NULL    COMMENT '创建时间',
        `updateTime` datetime     COMMENT '更新时间',
        PRIMARY KEY  (`id`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='异常日志';
    </update>

    <!-- 表所有列 -->
    <sql id="_columns">
        <trim suffixOverrides="," suffix="">
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('id') or colPickMode == 1 and data.containsKey('id')))">
                a.id,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('traceID') or colPickMode == 1 and data.containsKey('traceID')))">
                a.traceID,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('appName') or colPickMode == 1 and data.containsKey('appName')))">
                a.appName,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('hostName') or colPickMode == 1 and data.containsKey('hostName')))">
                a.hostName,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('message') or colPickMode == 1 and data.containsKey('message')))">
                a.message,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('platform') or colPickMode == 1 and data.containsKey('platform')))">
                a.platform,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('culprit') or colPickMode == 1 and data.containsKey('culprit')))">
                a.culprit,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('tags') or colPickMode == 1 and data.containsKey('tags')))">
                a.tags,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('level') or colPickMode == 1 and data.containsKey('level')))">
                a.level,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('environment') or colPickMode == 1 and data.containsKey('environment')))">
                a.environment,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('releaseVersion') or colPickMode == 1 and data.containsKey('releaseVersion')))">
                a.releaseVersion,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('fingerprint') or colPickMode == 1 and data.containsKey('fingerprint')))">
                a.fingerprint,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('threadNo') or colPickMode == 1 and data.containsKey('threadNo')))">
                a.threadNo,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('checkNum') or colPickMode == 1 and data.containsKey('checkNum')))">
                a.checkNum,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('errorStack') or colPickMode == 1 and data.containsKey('errorStack')))">
                a.errorStack,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('context') or colPickMode == 1 and data.containsKey('context')))">
                a.context,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('extra') or colPickMode == 1 and data.containsKey('extra')))">
                a.extra,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('logTime') or colPickMode == 1 and data.containsKey('logTime')))">
                a.logTime,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createUserId') or colPickMode == 1 and data.containsKey('createUserId')))">
                a.createUserId,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createTime') or colPickMode == 1 and data.containsKey('createTime')))">
                a.createTime,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateTime') or colPickMode == 1 and data.containsKey('updateTime')))">
                a.updateTime,
            </if>
        </trim>
    </sql>
    <!-- 新增 区分主键自增加还是业务插入 -->
    <insert id="insert" parameterType="ErrorLogEntity" >
        insert into `${tableName}`
        (id,traceID,appName,hostName,message,platform,culprit,tags,level,environment,releaseVersion,fingerprint,threadNo,checkNum,errorStack,context,extra,logTime,createUserId,createTime,updateTime)
        VALUES
        (#{id},#{traceID},#{appName},#{hostName},#{message},#{platform},#{culprit},#{tags},#{level},#{environment},#{releaseVersion},#{fingerprint},#{threadNo},#{checkNum},#{errorStack},#{context},#{extra},#{logTime},#{createUserId},#{createTime},#{updateTime})
    </insert>

    <!-- 批量新增 -->
    <insert id="insertBatch" parameterType="paramDto">
        insert into `${tableName}`
        (id,traceID,appName,hostName,message,platform,culprit,tags,level,environment,releaseVersion,fingerprint,threadNo,checkNum,errorStack,context,extra,logTime,createUserId,createTime,updateTime)
        VALUES
        <foreach collection="data.dataList" item="item" index="index" separator="," >
            (#{item.id},#{item.traceID},#{item.appName},#{item.hostName},#{item.message},#{item.platform},#{item.culprit},#{item.tags},#{item.level},#{item.environment},#{item.releaseVersion},#{item.fingerprint},#{item.threadNo},#{item.checkNum},#{item.errorStack},#{item.context},#{item.extra},#{item.logTime},#{item.createUserId},#{item.createTime},#{item.updateTime})
        </foreach>
    </insert>


    <!-- 根据ParamDto更新 -->
    <update id="update" parameterType="paramDto">
        update `${tableName}` as a
        set
        <trim suffixOverrides="," suffix="">
            <if test="(colPickMode==0 and data.containsKey('traceID')) or (colPickMode==1 and !data.containsKey('traceID'))">
                a.traceID=#{data.traceID},
            </if>
            <if test="(colPickMode==0 and data.containsKey('appName')) or (colPickMode==1 and !data.containsKey('appName'))">
                a.appName=#{data.appName},
            </if>
            <if test="(colPickMode==0 and data.containsKey('hostName')) or (colPickMode==1 and !data.containsKey('hostName'))">
                a.hostName=#{data.hostName},
            </if>
            <if test="(colPickMode==0 and data.containsKey('message')) or (colPickMode==1 and !data.containsKey('message'))">
                a.message=#{data.message},
            </if>
            <if test="(colPickMode==0 and data.containsKey('platform')) or (colPickMode==1 and !data.containsKey('platform'))">
                a.platform=#{data.platform},
            </if>
            <if test="(colPickMode==0 and data.containsKey('culprit')) or (colPickMode==1 and !data.containsKey('culprit'))">
                a.culprit=#{data.culprit},
            </if>
            <if test="(colPickMode==0 and data.containsKey('tags')) or (colPickMode==1 and !data.containsKey('tags'))">
                a.tags=#{data.tags},
            </if>
            <if test="(colPickMode==0 and data.containsKey('level')) or (colPickMode==1 and !data.containsKey('level'))">
                a.level=#{data.level},
            </if>
            <if test="(colPickMode==0 and data.containsKey('environment')) or (colPickMode==1 and !data.containsKey('environment'))">
                a.environment=#{data.environment},
            </if>
            <if test="(colPickMode==0 and data.containsKey('releaseVersion')) or (colPickMode==1 and !data.containsKey('releaseVersion'))">
                a.releaseVersion=#{data.releaseVersion},
            </if>
            <if test="(colPickMode==0 and data.containsKey('fingerprint')) or (colPickMode==1 and !data.containsKey('fingerprint'))">
                a.fingerprint=#{data.fingerprint},
            </if>
            <if test="(colPickMode==0 and data.containsKey('threadNo')) or (colPickMode==1 and !data.containsKey('threadNo'))">
                a.threadNo=#{data.threadNo},
            </if>
            <if test="(colPickMode==0 and data.containsKey('checkNum')) or (colPickMode==1 and !data.containsKey('checkNum'))">
                a.checkNum=#{data.checkNum},
            </if>
            <if test="(colPickMode==0 and data.containsKey('checkNumIncrement')) or (colPickMode==1 and !data.containsKey('checkNumIncrement'))">
                a.checkNum=ifnull(a.checkNum,0) + #{data.checkNumIncrement},
            </if>
            <if test="(colPickMode==0 and data.containsKey('errorStack')) or (colPickMode==1 and !data.containsKey('errorStack'))">
                a.errorStack=#{data.errorStack},
            </if>
            <if test="(colPickMode==0 and data.containsKey('context')) or (colPickMode==1 and !data.containsKey('context'))">
                a.context=#{data.context},
            </if>
            <if test="(colPickMode==0 and data.containsKey('extra')) or (colPickMode==1 and !data.containsKey('extra'))">
                a.extra=#{data.extra},
            </if>
            <if test="(colPickMode==0 and data.containsKey('logTime')) or (colPickMode==1 and !data.containsKey('logTime'))">
                a.logTime=#{data.logTime},
            </if>
            <if test="(colPickMode==0 and data.containsKey('createUserId')) or (colPickMode==1 and !data.containsKey('createUserId'))">
                a.createUserId=#{data.createUserId},
            </if>
            <if test="(colPickMode==0 and data.containsKey('createUserIdIncrement')) or (colPickMode==1 and !data.containsKey('createUserIdIncrement'))">
                a.createUserId=ifnull(a.createUserId,0) + #{data.createUserIdIncrement},
            </if>
            <if test="(colPickMode==0 and data.containsKey('createTime')) or (colPickMode==1 and !data.containsKey('createTime'))">
                a.createTime=#{data.createTime},
            </if>
            <if test="(colPickMode==0 and data.containsKey('updateTime')) or (colPickMode==1 and !data.containsKey('updateTime'))">
                a.updateTime=#{data.updateTime},
            </if>
        </trim>
        <trim suffixOverrides="where" suffix="">
            where
            <trim prefixOverrides="and" prefix="">
                <include refid="_condition_"/>
            </trim>
        </trim>
    </update>
    <!-- 批量更新 -->
    <update id="updateBatch" parameterType="paramDto">
        update `${tableName}` as a
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="traceID=(case" suffix="ELSE traceID end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('traceID')) or (colPickMode==1 and !item.containsKey('traceID'))">
                        when a.id=#{item.id} then #{item.traceID}
                    </if>
                </foreach>
            </trim>
            <trim prefix="appName=(case" suffix="ELSE appName end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('appName')) or (colPickMode==1 and !item.containsKey('appName'))">
                        when a.id=#{item.id} then #{item.appName}
                    </if>
                </foreach>
            </trim>
            <trim prefix="hostName=(case" suffix="ELSE hostName end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('hostName')) or (colPickMode==1 and !item.containsKey('hostName'))">
                        when a.id=#{item.id} then #{item.hostName}
                    </if>
                </foreach>
            </trim>
            <trim prefix="message=(case" suffix="ELSE message end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('message')) or (colPickMode==1 and !item.containsKey('message'))">
                        when a.id=#{item.id} then #{item.message}
                    </if>
                </foreach>
            </trim>
            <trim prefix="platform=(case" suffix="ELSE platform end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('platform')) or (colPickMode==1 and !item.containsKey('platform'))">
                        when a.id=#{item.id} then #{item.platform}
                    </if>
                </foreach>
            </trim>
            <trim prefix="culprit=(case" suffix="ELSE culprit end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('culprit')) or (colPickMode==1 and !item.containsKey('culprit'))">
                        when a.id=#{item.id} then #{item.culprit}
                    </if>
                </foreach>
            </trim>
            <trim prefix="tags=(case" suffix="ELSE tags end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('tags')) or (colPickMode==1 and !item.containsKey('tags'))">
                        when a.id=#{item.id} then #{item.tags}
                    </if>
                </foreach>
            </trim>
            <trim prefix="level=(case" suffix="ELSE level end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('level')) or (colPickMode==1 and !item.containsKey('level'))">
                        when a.id=#{item.id} then #{item.level}
                    </if>
                </foreach>
            </trim>
            <trim prefix="environment=(case" suffix="ELSE environment end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('environment')) or (colPickMode==1 and !item.containsKey('environment'))">
                        when a.id=#{item.id} then #{item.environment}
                    </if>
                </foreach>
            </trim>
            <trim prefix="releaseVersion=(case" suffix="ELSE releaseVersion end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('releaseVersion')) or (colPickMode==1 and !item.containsKey('releaseVersion'))">
                        when a.id=#{item.id} then #{item.releaseVersion}
                    </if>
                </foreach>
            </trim>
            <trim prefix="fingerprint=(case" suffix="ELSE fingerprint end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('fingerprint')) or (colPickMode==1 and !item.containsKey('fingerprint'))">
                        when a.id=#{item.id} then #{item.fingerprint}
                    </if>
                </foreach>
            </trim>
            <trim prefix="threadNo=(case" suffix="ELSE threadNo end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('threadNo')) or (colPickMode==1 and !item.containsKey('threadNo'))">
                        when a.id=#{item.id} then #{item.threadNo}
                    </if>
                </foreach>
            </trim>
            <trim prefix="checkNum=(case" suffix="ELSE checkNum end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <choose>
                        <when test="(colPickMode==0 and item.containsKey('checkNum')) or (colPickMode==1 and !item.containsKey('checkNum'))">
                            when a.id=#{item.id} then #{item.checkNum}
                        </when>
                        <when test="(colPickMode==0 and item.containsKey('checkNumIncrement')) or (colPickMode==1 and !item.containsKey('checkNumIncrement'))">
                            when a.id=#{item.id} then ifnull(a.checkNum,0) + #{item.checkNumIncrement}
                        </when>
                    </choose>
                </foreach>
            </trim>
            <trim prefix="errorStack=(case" suffix="ELSE errorStack end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('errorStack')) or (colPickMode==1 and !item.containsKey('errorStack'))">
                        when a.id=#{item.id} then #{item.errorStack}
                    </if>
                </foreach>
            </trim>
            <trim prefix="context=(case" suffix="ELSE context end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('context')) or (colPickMode==1 and !item.containsKey('context'))">
                        when a.id=#{item.id} then #{item.context}
                    </if>
                </foreach>
            </trim>
            <trim prefix="extra=(case" suffix="ELSE extra end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('extra')) or (colPickMode==1 and !item.containsKey('extra'))">
                        when a.id=#{item.id} then #{item.extra}
                    </if>
                </foreach>
            </trim>
            <trim prefix="logTime=(case" suffix="ELSE logTime end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('logTime')) or (colPickMode==1 and !item.containsKey('logTime'))">
                        when a.id=#{item.id} then #{item.logTime}
                    </if>
                </foreach>
            </trim>
            <trim prefix="createUserId=(case" suffix="ELSE createUserId end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <choose>
                        <when test="(colPickMode==0 and item.containsKey('createUserId')) or (colPickMode==1 and !item.containsKey('createUserId'))">
                            when a.id=#{item.id} then #{item.createUserId}
                        </when>
                        <when test="(colPickMode==0 and item.containsKey('createUserIdIncrement')) or (colPickMode==1 and !item.containsKey('createUserIdIncrement'))">
                            when a.id=#{item.id} then ifnull(a.createUserId,0) + #{item.createUserIdIncrement}
                        </when>
                    </choose>
                </foreach>
            </trim>
            <trim prefix="createTime=(case" suffix="ELSE createTime end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('createTime')) or (colPickMode==1 and !item.containsKey('createTime'))">
                        when a.id=#{item.id} then #{item.createTime}
                    </if>
                </foreach>
            </trim>
            <trim prefix="updateTime=(case" suffix="ELSE updateTime end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('updateTime')) or (colPickMode==1 and !item.containsKey('updateTime'))">
                        when a.id=#{item.id} then #{item.updateTime}
                    </if>
                </foreach>
            </trim>
        </trim>
        where id in
        <foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")">
            #{item.id}
        </foreach>
    </update>
    <!-- 根据主健查询 -->
    <select id="getByKey" parameterType="paramDto" resultMap="ErrorLogEntity-Map">
        select <include refid="_columns"/>
        from `${tableName}` as a
        where a.id=#{condition.id}
    </select>
    <!-- 根据主健删除 -->
    <delete id="deleteByKey" parameterType="paramDto">
        delete a.* from `${tableName}` as a where a.id=#{condition.id}
    </delete>
    <!-- 根据主健删除一批，针对单一主健有效 -->
    <delete id="deleteByKeys">
        delete from `${tableName}` where id in
        <foreach collection="array" item="item" index="index" open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>
    <!-- 根据paramDto删除一批 -->
    <delete id="deleteByMap" parameterType="paramDto">
        delete a.* from `${tableName}` as a
        <trim suffixOverrides="where" suffix="">
            where
            <trim prefixOverrides="and" prefix="">
                <include refid="_condition_"/>
            </trim>
        </trim>
    </delete>
    <!-- 获取列表 -->
    <select id="getList" parameterType="paramDto" resultMap="ErrorLogEntity-Map">
        select <include refid="_columns"/>
        from `${tableName}` as a
        <trim suffixOverrides="where" suffix="">
            where
            <trim prefixOverrides="and" prefix="">
                <include refid="_condition_"/>
            </trim>
        </trim>
        <include refid="_orderCols_"/>
    </select>



    <!-- 获取 -->
    <select id="getListCount" parameterType="paramDto" resultType="int">
        select count(1)
        from `${tableName}` as a
        <trim suffixOverrides="where" suffix="">
            where
            <trim prefixOverrides="and" prefix="">
                <include refid="_condition_"/>
            </trim>
        </trim>
    </select>
    <!-- 条件映射 -->
    <sql id="_condition_">
        <if test="condition != null and !condition.isEmpty()">
            <!-- 条件映射-普通条件 -->
            <include refid="_condition_param_">
                <property name="_conditionParam_" value="condition"/>
                <property name="_conditionType_" value="and"/>
            </include>
            <!-- 条件映射-集合之间使用AND，集合中元素使用OR-(list[0].1 or list[0].2) and (list[1].3 or list[1].4) -->
            <if test="condition.containsKey('andConditionList') and !condition.andConditionList.isEmpty()">
                and
                <foreach collection="condition.andConditionList" open="(" close=")" index="index" item="andCondition" separator=" and ">
                    <trim prefixOverrides="or" prefix="(" suffix=")">
                        <include refid="_condition_param_">
                            <property name="_conditionParam_" value="andCondition"/>
                            <property name="_conditionType_" value="or"/>
                        </include>
                    </trim>
                </foreach>
            </if>
            <!-- 条件映射-集合之间使用OR，集合中元素使用AND-(list[0].1 and list[0].2) or (list[1].3 and list[1].4) -->
            <if test="condition.containsKey('orConditionList') and !condition.orConditionList.isEmpty()">
                and
                <foreach collection="condition.orConditionList" open="(" close=")" index="index" item="orCondition" separator=" or ">
                    <trim prefixOverrides="and" prefix="(" suffix=")">
                        <include refid="_condition_param_">
                            <property name="_conditionParam_" value="orCondition"/>
                            <property name="_conditionType_" value="and"/>
                        </include>
                    </trim>
                </foreach>
            </if>
        </if>
    </sql>
    <!-- 条件映射-代参数 -->
    <sql id="_condition_param_">
        <bind name="conditionParamRef" value="${_conditionParam_}"/>
        <if test="conditionParamRef.containsKey('id')">
            <if test="conditionParamRef.id != null">
                ${_conditionType_} a.id=#{${_conditionParam_}.id}
            </if>
        </if>
        <if test="conditionParamRef.containsKey('id')">
            <if test="conditionParamRef.id != null ">
                ${_conditionType_} a.id = #{${_conditionParam_}.id}
            </if>
            <if test="conditionParamRef.id == null">
                ${_conditionType_} a.id is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('idList')">
            ${_conditionType_} a.id in
            <foreach collection="conditionParamRef.idList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="conditionParamRef.containsKey('idStart') and conditionParamRef.idStart != null">
            ${_conditionType_} a.id <![CDATA[ >= ]]> #{${_conditionParam_}.idStart}
        </if>
        <if test="conditionParamRef.containsKey('idEnd') and conditionParamRef.idEnd != null">
            ${_conditionType_} a.id <![CDATA[ <= ]]> #{${_conditionParam_}.idEnd}
        </if>


        <if test="conditionParamRef.containsKey('traceID')">
            <if test="conditionParamRef.traceID != null and conditionParamRef.traceID != ''">
                ${_conditionType_} a.traceID like #{${_conditionParam_}.traceID}
            </if>
            <if test="conditionParamRef.traceID == null">
                ${_conditionType_} a.traceID is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('traceIDList')">
            ${_conditionType_} a.traceID in
            <foreach collection="conditionParamRef.traceIDList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>

        <if test="conditionParamRef.containsKey('appName')">
            <if test="conditionParamRef.appName != null and conditionParamRef.appName != ''">
                ${_conditionType_} a.appName like #{${_conditionParam_}.appName}
            </if>
            <if test="conditionParamRef.appName == null">
                ${_conditionType_} a.appName is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('appNameList')">
            ${_conditionType_} a.appName in
            <foreach collection="conditionParamRef.appNameList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>

        <if test="conditionParamRef.containsKey('hostName')">
            <if test="conditionParamRef.hostName != null and conditionParamRef.hostName != ''">
                ${_conditionType_} a.hostName like #{${_conditionParam_}.hostName}
            </if>
            <if test="conditionParamRef.hostName == null">
                ${_conditionType_} a.hostName is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('hostNameList')">
            ${_conditionType_} a.hostName in
            <foreach collection="conditionParamRef.hostNameList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>

        <if test="conditionParamRef.containsKey('message')">
            <if test="conditionParamRef.message != null and conditionParamRef.message != ''">
                ${_conditionType_} a.message like #{${_conditionParam_}.message}
            </if>
            <if test="conditionParamRef.message == null">
                ${_conditionType_} a.message is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('messageList')">
            ${_conditionType_} a.message in
            <foreach collection="conditionParamRef.messageList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>

        <if test="conditionParamRef.containsKey('platform')">
            <if test="conditionParamRef.platform != null and conditionParamRef.platform != ''">
                ${_conditionType_} a.platform like #{${_conditionParam_}.platform}
            </if>
            <if test="conditionParamRef.platform == null">
                ${_conditionType_} a.platform is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('platformList')">
            ${_conditionType_} a.platform in
            <foreach collection="conditionParamRef.platformList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>

        <if test="conditionParamRef.containsKey('culprit')">
            <if test="conditionParamRef.culprit != null and conditionParamRef.culprit != ''">
                ${_conditionType_} a.culprit like #{${_conditionParam_}.culprit}
            </if>
            <if test="conditionParamRef.culprit == null">
                ${_conditionType_} a.culprit is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('culpritList')">
            ${_conditionType_} a.culprit in
            <foreach collection="conditionParamRef.culpritList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>

        <if test="conditionParamRef.containsKey('tags')">
            <if test="conditionParamRef.tags != null and conditionParamRef.tags != ''">
                ${_conditionType_} a.tags like #{${_conditionParam_}.tags}
            </if>
            <if test="conditionParamRef.tags == null">
                ${_conditionType_} a.tags is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('tagsList')">
            ${_conditionType_} a.tags in
            <foreach collection="conditionParamRef.tagsList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>

        <if test="conditionParamRef.containsKey('level')">
            <if test="conditionParamRef.level != null and conditionParamRef.level != ''">
                ${_conditionType_} a.level like #{${_conditionParam_}.level}
            </if>
            <if test="conditionParamRef.level == null">
                ${_conditionType_} a.level is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('levelList')">
            ${_conditionType_} a.level in
            <foreach collection="conditionParamRef.levelList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>

        <if test="conditionParamRef.containsKey('environment')">
            <if test="conditionParamRef.environment != null and conditionParamRef.environment != ''">
                ${_conditionType_} a.environment like #{${_conditionParam_}.environment}
            </if>
            <if test="conditionParamRef.environment == null">
                ${_conditionType_} a.environment is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('environmentList')">
            ${_conditionType_} a.environment in
            <foreach collection="conditionParamRef.environmentList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>

        <if test="conditionParamRef.containsKey('releaseVersion')">
            <if test="conditionParamRef.releaseVersion != null and conditionParamRef.releaseVersion != ''">
                ${_conditionType_} a.releaseVersion like #{${_conditionParam_}.releaseVersion}
            </if>
            <if test="conditionParamRef.releaseVersion == null">
                ${_conditionType_} a.releaseVersion is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('releaseVersionList')">
            ${_conditionType_} a.releaseVersion in
            <foreach collection="conditionParamRef.releaseVersionList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>

        <if test="conditionParamRef.containsKey('fingerprint')">
            <if test="conditionParamRef.fingerprint != null and conditionParamRef.fingerprint != ''">
                ${_conditionType_} a.fingerprint like #{${_conditionParam_}.fingerprint}
            </if>
            <if test="conditionParamRef.fingerprint == null">
                ${_conditionType_} a.fingerprint is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('fingerprintList')">
            ${_conditionType_} a.fingerprint in
            <foreach collection="conditionParamRef.fingerprintList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>

        <if test="conditionParamRef.containsKey('threadNo')">
            <if test="conditionParamRef.threadNo != null and conditionParamRef.threadNo != ''">
                ${_conditionType_} a.threadNo like #{${_conditionParam_}.threadNo}
            </if>
            <if test="conditionParamRef.threadNo == null">
                ${_conditionType_} a.threadNo is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('threadNoList')">
            ${_conditionType_} a.threadNo in
            <foreach collection="conditionParamRef.threadNoList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="conditionParamRef.containsKey('checkNum')">
            <if test="conditionParamRef.checkNum != null ">
                ${_conditionType_} a.checkNum = #{${_conditionParam_}.checkNum}
            </if>
            <if test="conditionParamRef.checkNum == null">
                ${_conditionType_} a.checkNum is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('checkNumList')">
            ${_conditionType_} a.checkNum in
            <foreach collection="conditionParamRef.checkNumList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="conditionParamRef.containsKey('checkNumStart') and conditionParamRef.checkNumStart != null">
            ${_conditionType_} a.checkNum <![CDATA[ >= ]]> #{${_conditionParam_}.checkNumStart}
        </if>
        <if test="conditionParamRef.containsKey('checkNumEnd') and conditionParamRef.checkNumEnd != null">
            ${_conditionType_} a.checkNum <![CDATA[ <= ]]> #{${_conditionParam_}.checkNumEnd}
        </if>


        <if test="conditionParamRef.containsKey('errorStack')">
            <if test="conditionParamRef.errorStack != null and conditionParamRef.errorStack != ''">
                ${_conditionType_} a.errorStack like #{${_conditionParam_}.errorStack}
            </if>
            <if test="conditionParamRef.errorStack == null">
                ${_conditionType_} a.errorStack is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('errorStackList')">
            ${_conditionType_} a.errorStack in
            <foreach collection="conditionParamRef.errorStackList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>

        <if test="conditionParamRef.containsKey('context')">
            <if test="conditionParamRef.context != null and conditionParamRef.context != ''">
                ${_conditionType_} a.context like #{${_conditionParam_}.context}
            </if>
            <if test="conditionParamRef.context == null">
                ${_conditionType_} a.context is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('contextList')">
            ${_conditionType_} a.context in
            <foreach collection="conditionParamRef.contextList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>

        <if test="conditionParamRef.containsKey('extra')">
            <if test="conditionParamRef.extra != null and conditionParamRef.extra != ''">
                ${_conditionType_} a.extra like #{${_conditionParam_}.extra}
            </if>
            <if test="conditionParamRef.extra == null">
                ${_conditionType_} a.extra is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('extraList')">
            ${_conditionType_} a.extra in
            <foreach collection="conditionParamRef.extraList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>

        <if test="conditionParamRef.containsKey('logTime')">
            <if test="conditionParamRef.logTime != null ">
                ${_conditionType_} a.logTime = #{${_conditionParam_}.logTime}
            </if>
            <if test="conditionParamRef.logTime == null">
                ${_conditionType_} a.logTime is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('logTimeStart') and conditionParamRef.logTimeStart != null and conditionParamRef.logTimeStart!=''">
            ${_conditionType_} a.logTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.logTimeStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s')
        </if>
        <if test="conditionParamRef.containsKey('logTimeEnd') and conditionParamRef.logTimeEnd != null and conditionParamRef.logTimeEnd!=''">
            ${_conditionType_} a.logTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.logTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
        </if>
        <if test="conditionParamRef.containsKey('createUserId')">
            <if test="conditionParamRef.createUserId != null ">
                ${_conditionType_} a.createUserId = #{${_conditionParam_}.createUserId}
            </if>
            <if test="conditionParamRef.createUserId == null">
                ${_conditionType_} a.createUserId is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('createUserIdList')">
            ${_conditionType_} a.createUserId in
            <foreach collection="conditionParamRef.createUserIdList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="conditionParamRef.containsKey('createUserIdStart') and conditionParamRef.createUserIdStart != null">
            ${_conditionType_} a.createUserId <![CDATA[ >= ]]> #{${_conditionParam_}.createUserIdStart}
        </if>
        <if test="conditionParamRef.containsKey('createUserIdEnd') and conditionParamRef.createUserIdEnd != null">
            ${_conditionType_} a.createUserId <![CDATA[ <= ]]> #{${_conditionParam_}.createUserIdEnd}
        </if>


        <if test="conditionParamRef.containsKey('createTime')">
            <if test="conditionParamRef.createTime != null ">
                ${_conditionType_} a.createTime = #{${_conditionParam_}.createTime}
            </if>
            <if test="conditionParamRef.createTime == null">
                ${_conditionType_} a.createTime is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('createTimeStart') and conditionParamRef.createTimeStart != null and conditionParamRef.createTimeStart!=''">
            ${_conditionType_} a.createTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.createTimeStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s')
        </if>
        <if test="conditionParamRef.containsKey('createTimeEnd') and conditionParamRef.createTimeEnd != null and conditionParamRef.createTimeEnd!=''">
            ${_conditionType_} a.createTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.createTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
        </if>

        <if test="conditionParamRef.containsKey('updateTime')">
            <if test="conditionParamRef.updateTime != null ">
                ${_conditionType_} a.updateTime = #{${_conditionParam_}.updateTime}
            </if>
            <if test="conditionParamRef.updateTime == null">
                ${_conditionType_} a.updateTime is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('updateTimeStart') and conditionParamRef.updateTimeStart != null and conditionParamRef.updateTimeStart!=''">
            ${_conditionType_} a.updateTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.updateTimeStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s')
        </if>
        <if test="conditionParamRef.containsKey('updateTimeEnd') and conditionParamRef.updateTimeEnd != null and conditionParamRef.updateTimeEnd!=''">
            ${_conditionType_} a.updateTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.updateTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
        </if>
    </sql>
    <sql id="_orderCols_">
        <if test="orderColList != null and !orderColList.isEmpty()">
            order by
            <trim suffixOverrides=","  suffix="">
                <foreach collection="orderColList" open="" close="" index="index" item="item" separator=",">
                    ${item.colName} ${item.sortKind}
                </foreach>
            </trim>
        </if>
        <if test="(orderColList == null or orderColList.isEmpty()) and orderCol != null and !orderCol.isEmpty()">
            order by
            <trim suffixOverrides=","  suffix="">
                <if test="orderCol.containsKey('id')">
                    a.id
                    <if test='orderCol.id != null and "DESC".equalsIgnoreCase(orderCol.id)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('traceID')">
                    a.traceID
                    <if test='orderCol.traceID != null and "DESC".equalsIgnoreCase(orderCol.traceID)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('appName')">
                    a.appName
                    <if test='orderCol.appName != null and "DESC".equalsIgnoreCase(orderCol.appName)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('hostName')">
                    a.hostName
                    <if test='orderCol.hostName != null and "DESC".equalsIgnoreCase(orderCol.hostName)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('message')">
                    a.message
                    <if test='orderCol.message != null and "DESC".equalsIgnoreCase(orderCol.message)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('platform')">
                    a.platform
                    <if test='orderCol.platform != null and "DESC".equalsIgnoreCase(orderCol.platform)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('culprit')">
                    a.culprit
                    <if test='orderCol.culprit != null and "DESC".equalsIgnoreCase(orderCol.culprit)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('tags')">
                    a.tags
                    <if test='orderCol.tags != null and "DESC".equalsIgnoreCase(orderCol.tags)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('level')">
                    a.level
                    <if test='orderCol.level != null and "DESC".equalsIgnoreCase(orderCol.level)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('environment')">
                    a.environment
                    <if test='orderCol.environment != null and "DESC".equalsIgnoreCase(orderCol.environment)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('releaseVersion')">
                    a.releaseVersion
                    <if test='orderCol.releaseVersion != null and "DESC".equalsIgnoreCase(orderCol.releaseVersion)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('fingerprint')">
                    a.fingerprint
                    <if test='orderCol.fingerprint != null and "DESC".equalsIgnoreCase(orderCol.fingerprint)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('threadNo')">
                    a.threadNo
                    <if test='orderCol.threadNo != null and "DESC".equalsIgnoreCase(orderCol.threadNo)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('checkNum')">
                    a.checkNum
                    <if test='orderCol.checkNum != null and "DESC".equalsIgnoreCase(orderCol.checkNum)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('errorStack')">
                    a.errorStack
                    <if test='orderCol.errorStack != null and "DESC".equalsIgnoreCase(orderCol.errorStack)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('context')">
                    a.context
                    <if test='orderCol.context != null and "DESC".equalsIgnoreCase(orderCol.context)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('extra')">
                    a.extra
                    <if test='orderCol.extra != null and "DESC".equalsIgnoreCase(orderCol.extra)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('logTime')">
                    a.logTime
                    <if test='orderCol.logTime != null and "DESC".equalsIgnoreCase(orderCol.logTime)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('createUserId')">
                    a.createUserId
                    <if test='orderCol.createUserId != null and "DESC".equalsIgnoreCase(orderCol.createUserId)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('createTime')">
                    a.createTime
                    <if test='orderCol.createTime != null and "DESC".equalsIgnoreCase(orderCol.createTime)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('updateTime')">
                    a.updateTime
                    <if test='orderCol.updateTime != null and "DESC".equalsIgnoreCase(orderCol.updateTime)'>DESC</if>
                    ,
                </if>
            </trim>
        </if>
    </sql>
    <sql id="_group_by_">
        <if test="groupList != null and !groupList.isEmpty()">
            GROUP BY
            <trim suffixOverrides=","  suffix="">
                <foreach collection="groupList" open="" close="" index="index" item="item" separator=",">
                    ${item}
                </foreach>
            </trim>
        </if>
    </sql>
</mapper>