<?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.biz.dao.ibatis.BizLogDaoImpl">

    <!-- 字段和属性映射 -->
    <resultMap type="BizLogEntity" id="BizLogEntity-Map">
            <id  property="id" column="id" />
            <result property="traceID" column="traceID" />
            <result property="appName" column="appName" />
            <result property="hostName" column="hostName" />
            <result property="logLevel" column="logLevel" />
            <result property="userCode" column="userCode" />
            <result property="deviceCode" column="deviceCode" />
            <result property="eventTopic" column="eventTopic" />
            <result property="eventTopicName" column="eventTopicName" />
            <result property="msg" column="msg" />
            <result property="logTime" column="logTime" />
            <result property="createUserId" column="createUserId" />
            <result property="createTime" column="createTime" />
            
    </resultMap>

    <update id="createTable" parameterType="paramDto">
        CREATE TABLE `${tableName}`(
        `id` bigint(20)   AUTO_INCREMENT  COMMENT '主键ID，主键，自增长',
        `traceID` varchar(64)     COMMENT '追踪Id',
        `appName` varchar(64)     COMMENT '应用名称',
        `hostName` varchar(64)     COMMENT '实例IP',
        `logLevel` varchar(64)     COMMENT '日志等级',
        `userCode` varchar(64)     COMMENT '用户唯一标识',
        `deviceCode` varchar(64)     COMMENT '设备唯一标识',
        `eventTopic` varchar(64)     COMMENT '记录埋点的事件主题，方便实时计算或同步进行数据筛选',
        `eventTopicName` varchar(64)     COMMENT '记录埋点中文名称',
        `msg` mediumtext     COMMENT '事件参数，json',
        `logTime` datetime NOT NULL    COMMENT '日志产生时间',
        `createUserId` bigint(20) NOT NULL    COMMENT '创建用户',
        `createTime` datetime NOT NULL    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('logLevel') or colPickMode == 1 and data.containsKey('logLevel')))">
                    a.logLevel,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('userCode') or colPickMode == 1 and data.containsKey('userCode')))">
                    a.userCode,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceCode') or colPickMode == 1 and data.containsKey('deviceCode')))">
                    a.deviceCode,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('eventTopic') or colPickMode == 1 and data.containsKey('eventTopic')))">
                    a.eventTopic,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('eventTopicName') or colPickMode == 1 and data.containsKey('eventTopicName')))">
                    a.eventTopicName,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('msg') or colPickMode == 1 and data.containsKey('msg')))">
                    a.msg,
                </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>
        </trim>
    </sql>
    <!-- 新增 区分主键自增加还是业务插入 -->
    <insert id="insert" parameterType="BizLogEntity" >
        insert into `${tableName}`
        (id,traceID,appName,hostName,logLevel,userCode,deviceCode,eventTopic,eventTopicName,msg,logTime,createUserId,createTime)
        VALUES
        (#{id},#{traceID},#{appName},#{hostName},#{logLevel},#{userCode},#{deviceCode},#{eventTopic},#{eventTopicName},#{msg},#{logTime},#{createUserId},#{createTime})
    </insert>

    <!-- 批量新增 -->
    <insert id="insertBatch" parameterType="paramDto">
        insert into `${tableName}`
        (id,traceID,appName,hostName,logLevel,userCode,deviceCode,eventTopic,eventTopicName,msg,logTime,createUserId,createTime)
        VALUES
        <foreach collection="data.dataList" item="item" index="index" separator="," >
            (#{item.id},#{item.traceID},#{item.appName},#{item.hostName},#{item.logLevel},#{item.userCode},#{item.deviceCode},#{item.eventTopic},#{item.eventTopicName},#{item.msg},#{item.logTime},#{item.createUserId},#{item.createTime})
        </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('logLevel')) or (colPickMode==1 and !data.containsKey('logLevel'))">
                a.logLevel=#{data.logLevel},
            </if>
            <if test="(colPickMode==0 and data.containsKey('userCode')) or (colPickMode==1 and !data.containsKey('userCode'))">
                a.userCode=#{data.userCode},
            </if>
            <if test="(colPickMode==0 and data.containsKey('deviceCode')) or (colPickMode==1 and !data.containsKey('deviceCode'))">
                a.deviceCode=#{data.deviceCode},
            </if>
            <if test="(colPickMode==0 and data.containsKey('eventTopic')) or (colPickMode==1 and !data.containsKey('eventTopic'))">
                a.eventTopic=#{data.eventTopic},
            </if>
            <if test="(colPickMode==0 and data.containsKey('eventTopicName')) or (colPickMode==1 and !data.containsKey('eventTopicName'))">
                a.eventTopicName=#{data.eventTopicName},
            </if>
            <if test="(colPickMode==0 and data.containsKey('msg')) or (colPickMode==1 and !data.containsKey('msg'))">
                a.msg=#{data.msg},
            </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>
        </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="logLevel=(case" suffix="ELSE logLevel end),">
                    <foreach collection="data.dataList" item="item" index="index" separator="" >
                        <if test="(colPickMode==0 and item.containsKey('logLevel')) or (colPickMode==1 and !item.containsKey('logLevel'))">
                            when a.id=#{item.id} then #{item.logLevel}
                        </if>
                    </foreach>
                </trim>
                <trim prefix="userCode=(case" suffix="ELSE userCode end),">
                    <foreach collection="data.dataList" item="item" index="index" separator="" >
                        <if test="(colPickMode==0 and item.containsKey('userCode')) or (colPickMode==1 and !item.containsKey('userCode'))">
                            when a.id=#{item.id} then #{item.userCode}
                        </if>
                    </foreach>
                </trim>
                <trim prefix="deviceCode=(case" suffix="ELSE deviceCode end),">
                    <foreach collection="data.dataList" item="item" index="index" separator="" >
                        <if test="(colPickMode==0 and item.containsKey('deviceCode')) or (colPickMode==1 and !item.containsKey('deviceCode'))">
                            when a.id=#{item.id} then #{item.deviceCode}
                        </if>
                    </foreach>
                </trim>
                <trim prefix="eventTopic=(case" suffix="ELSE eventTopic end),">
                    <foreach collection="data.dataList" item="item" index="index" separator="" >
                        <if test="(colPickMode==0 and item.containsKey('eventTopic')) or (colPickMode==1 and !item.containsKey('eventTopic'))">
                            when a.id=#{item.id} then #{item.eventTopic}
                        </if>
                    </foreach>
                </trim>
                <trim prefix="eventTopicName=(case" suffix="ELSE eventTopicName end),">
                    <foreach collection="data.dataList" item="item" index="index" separator="" >
                        <if test="(colPickMode==0 and item.containsKey('eventTopicName')) or (colPickMode==1 and !item.containsKey('eventTopicName'))">
                            when a.id=#{item.id} then #{item.eventTopicName}
                        </if>
                    </foreach>
                </trim>
                <trim prefix="msg=(case" suffix="ELSE msg end),">
                    <foreach collection="data.dataList" item="item" index="index" separator="" >
                        <if test="(colPickMode==0 and item.containsKey('msg')) or (colPickMode==1 and !item.containsKey('msg'))">
                            when a.id=#{item.id} then #{item.msg}
                        </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>
        where id in
        <foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")">
            #{item.id}
        </foreach>
    </update>
    <!-- 根据主健查询 -->
    <select id="getByKey" parameterType="paramDto" resultMap="BizLogEntity-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="BizLogEntity-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('logLevel')">
                <if test="conditionParamRef.logLevel != null and conditionParamRef.logLevel != ''">
                    ${_conditionType_} a.logLevel like #{${_conditionParam_}.logLevel}
                </if>
                <if test="conditionParamRef.logLevel == null">
                    ${_conditionType_} a.logLevel is null
                </if>
            </if>
            <if test="conditionParamRef.containsKey('logLevelList')">
                ${_conditionType_} a.logLevel in
                <foreach collection="conditionParamRef.logLevelList" open="(" close=")" index="index" item="item" separator=",">
                    #{item}
                </foreach>
            </if>

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

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

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

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

            <if test="conditionParamRef.containsKey('msg')">
                <if test="conditionParamRef.msg != null and conditionParamRef.msg != ''">
                    ${_conditionType_} a.msg like #{${_conditionParam_}.msg}
                </if>
                <if test="conditionParamRef.msg == null">
                    ${_conditionType_} a.msg is null
                </if>
            </if>
            <if test="conditionParamRef.containsKey('msgList')">
                ${_conditionType_} a.msg in
                <foreach collection="conditionParamRef.msgList" 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>
    </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('logLevel')">
                        a.logLevel
                        <if test='orderCol.logLevel != null and "DESC".equalsIgnoreCase(orderCol.logLevel)'>DESC</if>
                        ,
                    </if>
                    <if test="orderCol.containsKey('userCode')">
                        a.userCode
                        <if test='orderCol.userCode != null and "DESC".equalsIgnoreCase(orderCol.userCode)'>DESC</if>
                        ,
                    </if>
                    <if test="orderCol.containsKey('deviceCode')">
                        a.deviceCode
                        <if test='orderCol.deviceCode != null and "DESC".equalsIgnoreCase(orderCol.deviceCode)'>DESC</if>
                        ,
                    </if>
                    <if test="orderCol.containsKey('eventTopic')">
                        a.eventTopic
                        <if test='orderCol.eventTopic != null and "DESC".equalsIgnoreCase(orderCol.eventTopic)'>DESC</if>
                        ,
                    </if>
                    <if test="orderCol.containsKey('eventTopicName')">
                        a.eventTopicName
                        <if test='orderCol.eventTopicName != null and "DESC".equalsIgnoreCase(orderCol.eventTopicName)'>DESC</if>
                        ,
                    </if>
                    <if test="orderCol.containsKey('msg')">
                        a.msg
                        <if test='orderCol.msg != null and "DESC".equalsIgnoreCase(orderCol.msg)'>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>
            </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>