<?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.operate.dao.ibatis.OperateLogDaoImpl">

    <!-- 字段和属性映射 -->
    <resultMap type="OperateLogEntity" id="OperateLogEntity-Map">
        <id  property="id" column="id" />
        <result property="platformMark" column="platformMark" />
        <result property="userId" column="userId" />
        <result property="userName" column="userName" />
        <result property="loginName" column="loginName" />
        <result property="requestUrl" column="requestUrl" />
        <result property="content" column="content" />
        <result property="ip" column="ip" />
        <result property="logDate" column="logDate" />
        <result property="operType" column="operType" />
        <result property="createUserId" column="createUserId" />
        <result property="createTime" column="createTime" />

    </resultMap>

    <update id="createTable" parameterType="paramDto">
        CREATE TABLE `${tableName}`(
        `id` bigint(20)     COMMENT '主键ID',
        `platformMark` varchar(50)     COMMENT '平台标识',
        `userId` bigint(20)     COMMENT '用户id',
        `userName` varchar(50)     COMMENT '用户名称',
        `loginName` varchar(50)     COMMENT '用户登录名',
        `requestUrl` varchar(200)     COMMENT '请求地址',
        `content` varchar(2048)     COMMENT '操作内容，记录操作具体信息，如修改前修改或的数据',
        `ip` varchar(30)     COMMENT '操作IP地址',
        `logDate` datetime     COMMENT '操作时间',
        `operType` tinyint(2)     COMMENT '操作类型，0：新增，1：修改，2：删除',
        `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('platformMark') or colPickMode == 1 and data.containsKey('platformMark')))">
                a.platformMark,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('userId') or colPickMode == 1 and data.containsKey('userId')))">
                a.userId,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('userName') or colPickMode == 1 and data.containsKey('userName')))">
                a.userName,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('loginName') or colPickMode == 1 and data.containsKey('loginName')))">
                a.loginName,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('requestUrl') or colPickMode == 1 and data.containsKey('requestUrl')))">
                a.requestUrl,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('content') or colPickMode == 1 and data.containsKey('content')))">
                a.content,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('ip') or colPickMode == 1 and data.containsKey('ip')))">
                a.ip,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('logDate') or colPickMode == 1 and data.containsKey('logDate')))">
                a.logDate,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('operType') or colPickMode == 1 and data.containsKey('operType')))">
                a.operType,
            </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="OperateLogEntity" >
        insert into `${tableName}`
        (id,platformMark,userId,userName,loginName,requestUrl,content,ip,logDate,operType,createUserId,createTime)
        VALUES
        (#{id},#{platformMark},#{userId},#{userName},#{loginName},#{requestUrl},#{content},#{ip},#{logDate},#{operType},#{createUserId},#{createTime})
    </insert>

    <!-- 批量新增 -->
    <insert id="insertBatch" parameterType="paramDto">
        insert into `${tableName}`
        (id,platformMark,userId,userName,loginName,requestUrl,content,ip,logDate,operType,createUserId,createTime)
        VALUES
        <foreach collection="data.dataList" item="item" index="index" separator="," >
            (#{item.id},#{item.platformMark},#{item.userId},#{item.userName},#{item.loginName},#{item.requestUrl},#{item.content},#{item.ip},#{item.logDate},#{item.operType},#{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('platformMark')) or (colPickMode==1 and !data.containsKey('platformMark'))">
                a.platformMark=#{data.platformMark},
            </if>
            <if test="(colPickMode==0 and data.containsKey('userId')) or (colPickMode==1 and !data.containsKey('userId'))">
                a.userId=#{data.userId},
            </if>
            <if test="(colPickMode==0 and data.containsKey('userIdIncrement')) or (colPickMode==1 and !data.containsKey('userIdIncrement'))">
                a.userId=ifnull(a.userId,0) + #{data.userIdIncrement},
            </if>
            <if test="(colPickMode==0 and data.containsKey('userName')) or (colPickMode==1 and !data.containsKey('userName'))">
                a.userName=#{data.userName},
            </if>
            <if test="(colPickMode==0 and data.containsKey('loginName')) or (colPickMode==1 and !data.containsKey('loginName'))">
                a.loginName=#{data.loginName},
            </if>
            <if test="(colPickMode==0 and data.containsKey('requestUrl')) or (colPickMode==1 and !data.containsKey('requestUrl'))">
                a.requestUrl=#{data.requestUrl},
            </if>
            <if test="(colPickMode==0 and data.containsKey('content')) or (colPickMode==1 and !data.containsKey('content'))">
                a.content=#{data.content},
            </if>
            <if test="(colPickMode==0 and data.containsKey('ip')) or (colPickMode==1 and !data.containsKey('ip'))">
                a.ip=#{data.ip},
            </if>
            <if test="(colPickMode==0 and data.containsKey('logDate')) or (colPickMode==1 and !data.containsKey('logDate'))">
                a.logDate=#{data.logDate},
            </if>
            <if test="(colPickMode==0 and data.containsKey('operType')) or (colPickMode==1 and !data.containsKey('operType'))">
                a.operType=#{data.operType},
            </if>
            <if test="(colPickMode==0 and data.containsKey('operTypeIncrement')) or (colPickMode==1 and !data.containsKey('operTypeIncrement'))">
                a.operType=ifnull(a.operType,0) + #{data.operTypeIncrement},
            </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="platformMark=(case" suffix="ELSE platformMark end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('platformMark')) or (colPickMode==1 and !item.containsKey('platformMark'))">
                        when a.id=#{item.id} then #{item.platformMark}
                    </if>
                </foreach>
            </trim>
            <trim prefix="userId=(case" suffix="ELSE userId end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <choose>
                        <when test="(colPickMode==0 and item.containsKey('userId')) or (colPickMode==1 and !item.containsKey('userId'))">
                            when a.id=#{item.id} then #{item.userId}
                        </when>
                        <when test="(colPickMode==0 and item.containsKey('userIdIncrement')) or (colPickMode==1 and !item.containsKey('userIdIncrement'))">
                            when a.id=#{item.id} then ifnull(a.userId,0) + #{item.userIdIncrement}
                        </when>
                    </choose>
                </foreach>
            </trim>
            <trim prefix="userName=(case" suffix="ELSE userName end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('userName')) or (colPickMode==1 and !item.containsKey('userName'))">
                        when a.id=#{item.id} then #{item.userName}
                    </if>
                </foreach>
            </trim>
            <trim prefix="loginName=(case" suffix="ELSE loginName end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('loginName')) or (colPickMode==1 and !item.containsKey('loginName'))">
                        when a.id=#{item.id} then #{item.loginName}
                    </if>
                </foreach>
            </trim>
            <trim prefix="requestUrl=(case" suffix="ELSE requestUrl end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('requestUrl')) or (colPickMode==1 and !item.containsKey('requestUrl'))">
                        when a.id=#{item.id} then #{item.requestUrl}
                    </if>
                </foreach>
            </trim>
            <trim prefix="content=(case" suffix="ELSE content end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('content')) or (colPickMode==1 and !item.containsKey('content'))">
                        when a.id=#{item.id} then #{item.content}
                    </if>
                </foreach>
            </trim>
            <trim prefix="ip=(case" suffix="ELSE ip end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('ip')) or (colPickMode==1 and !item.containsKey('ip'))">
                        when a.id=#{item.id} then #{item.ip}
                    </if>
                </foreach>
            </trim>
            <trim prefix="logDate=(case" suffix="ELSE logDate end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('logDate')) or (colPickMode==1 and !item.containsKey('logDate'))">
                        when a.id=#{item.id} then #{item.logDate}
                    </if>
                </foreach>
            </trim>
            <trim prefix="operType=(case" suffix="ELSE operType end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <choose>
                        <when test="(colPickMode==0 and item.containsKey('operType')) or (colPickMode==1 and !item.containsKey('operType'))">
                            when a.id=#{item.id} then #{item.operType}
                        </when>
                        <when test="(colPickMode==0 and item.containsKey('operTypeIncrement')) or (colPickMode==1 and !item.containsKey('operTypeIncrement'))">
                            when a.id=#{item.id} then ifnull(a.operType,0) + #{item.operTypeIncrement}
                        </when>
                    </choose>
                </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="OperateLogEntity-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="OperateLogEntity-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('platformMark')">
            <if test="conditionParamRef.platformMark != null and conditionParamRef.platformMark != ''">
                ${_conditionType_} a.platformMark like #{${_conditionParam_}.platformMark}
            </if>
            <if test="conditionParamRef.platformMark == null">
                ${_conditionType_} a.platformMark is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('platformMarkList')">
            ${_conditionType_} a.platformMark in
            <foreach collection="conditionParamRef.platformMarkList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="conditionParamRef.containsKey('userId')">
            <if test="conditionParamRef.userId != null ">
                ${_conditionType_} a.userId = #{${_conditionParam_}.userId}
            </if>
            <if test="conditionParamRef.userId == null">
                ${_conditionType_} a.userId is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('userIdList')">
            ${_conditionType_} a.userId in
            <foreach collection="conditionParamRef.userIdList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="conditionParamRef.containsKey('userIdStart') and conditionParamRef.userIdStart != null">
            ${_conditionType_} a.userId <![CDATA[ >= ]]> #{${_conditionParam_}.userIdStart}
        </if>
        <if test="conditionParamRef.containsKey('userIdEnd') and conditionParamRef.userIdEnd != null">
            ${_conditionType_} a.userId <![CDATA[ <= ]]> #{${_conditionParam_}.userIdEnd}
        </if>


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

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

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

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

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

        <if test="conditionParamRef.containsKey('logDate')">
            <if test="conditionParamRef.logDate != null ">
                ${_conditionType_} a.logDate = #{${_conditionParam_}.logDate}
            </if>
            <if test="conditionParamRef.logDate == null">
                ${_conditionType_} a.logDate is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('logDateStart') and conditionParamRef.logDateStart != null and conditionParamRef.logDateStart!=''">
            ${_conditionType_} a.logDate <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.logDateStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s')
        </if>
        <if test="conditionParamRef.containsKey('logDateEnd') and conditionParamRef.logDateEnd != null and conditionParamRef.logDateEnd!=''">
            ${_conditionType_} a.logDate <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.logDateEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
        </if>
        <if test="conditionParamRef.containsKey('operType')">
            <if test="conditionParamRef.operType != null ">
                ${_conditionType_} a.operType = #{${_conditionParam_}.operType}
            </if>
            <if test="conditionParamRef.operType == null">
                ${_conditionType_} a.operType is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('operTypeList')">
            ${_conditionType_} a.operType in
            <foreach collection="conditionParamRef.operTypeList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="conditionParamRef.containsKey('operTypeStart') and conditionParamRef.operTypeStart != null">
            ${_conditionType_} a.operType <![CDATA[ >= ]]> #{${_conditionParam_}.operTypeStart}
        </if>
        <if test="conditionParamRef.containsKey('operTypeEnd') and conditionParamRef.operTypeEnd != null">
            ${_conditionType_} a.operType <![CDATA[ <= ]]> #{${_conditionParam_}.operTypeEnd}
        </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('platformMark')">
                    a.platformMark
                    <if test='orderCol.platformMark != null and "DESC".equalsIgnoreCase(orderCol.platformMark)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('userId')">
                    a.userId
                    <if test='orderCol.userId != null and "DESC".equalsIgnoreCase(orderCol.userId)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('userName')">
                    a.userName
                    <if test='orderCol.userName != null and "DESC".equalsIgnoreCase(orderCol.userName)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('loginName')">
                    a.loginName
                    <if test='orderCol.loginName != null and "DESC".equalsIgnoreCase(orderCol.loginName)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('requestUrl')">
                    a.requestUrl
                    <if test='orderCol.requestUrl != null and "DESC".equalsIgnoreCase(orderCol.requestUrl)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('content')">
                    a.content
                    <if test='orderCol.content != null and "DESC".equalsIgnoreCase(orderCol.content)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('ip')">
                    a.ip
                    <if test='orderCol.ip != null and "DESC".equalsIgnoreCase(orderCol.ip)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('logDate')">
                    a.logDate
                    <if test='orderCol.logDate != null and "DESC".equalsIgnoreCase(orderCol.logDate)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('operType')">
                    a.operType
                    <if test='orderCol.operType != null and "DESC".equalsIgnoreCase(orderCol.operType)'>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>