<?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.base.system.user.dao.ibatis.UserDaoImpl">

    <!-- 字段和属性映射 -->
    <resultMap type="UserEntity" id="UserEntity-Map">
        <id  property="id" column="id" />
        <result property="loginName" column="loginName" />
        <result property="loginPwd" column="loginPwd" />
        <result property="loginLimitAddress" column="loginLimitAddress" />
        <result property="realName" column="realName" />
        <result property="mobile" column="mobile" />
        <result property="phone" column="phone" />
        <result property="email" column="email" />
        <result property="qq" column="qq" />
        <result property="userType" column="userType" />
        <result property="siteIds" column="siteIds" />
        <result property="areaCodes" column="areaCodes" />
        <result property="status" column="status" />
        <result property="createTime" column="createTime" />
        <result property="createUserId" column="createUserId" />
        <result property="createUserName" column="createUserName" />
        <result property="lastLoginTime" column="lastLoginTime" />
        <result property="lastLoginAddress" column="lastLoginAddress" />

    </resultMap>


    <!-- 表所有列 -->
    <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('loginName') or colPickMode == 1 and data.containsKey('loginName')))">
                a.loginName,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('loginPwd') or colPickMode == 1 and data.containsKey('loginPwd')))">
                a.loginPwd,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('loginLimitAddress') or colPickMode == 1 and data.containsKey('loginLimitAddress')))">
                a.loginLimitAddress,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('realName') or colPickMode == 1 and data.containsKey('realName')))">
                a.realName,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('mobile') or colPickMode == 1 and data.containsKey('mobile')))">
                a.mobile,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('phone') or colPickMode == 1 and data.containsKey('phone')))">
                a.phone,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('email') or colPickMode == 1 and data.containsKey('email')))">
                a.email,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('qq') or colPickMode == 1 and data.containsKey('qq')))">
                a.qq,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('userType') or colPickMode == 1 and data.containsKey('userType')))">
                a.userType,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('siteIds') or colPickMode == 1 and data.containsKey('siteIds')))">
                a.siteIds,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('areaCodes') or colPickMode == 1 and data.containsKey('areaCodes')))">
                a.areaCodes,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('status') or colPickMode == 1 and data.containsKey('status')))">
                a.status,
            </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('createUserId') or colPickMode == 1 and data.containsKey('createUserId')))">
                a.createUserId,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createUserName') or colPickMode == 1 and data.containsKey('createUserName')))">
                a.createUserName,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('lastLoginTime') or colPickMode == 1 and data.containsKey('lastLoginTime')))">
                a.lastLoginTime,
            </if>
            <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('lastLoginAddress') or colPickMode == 1 and data.containsKey('lastLoginAddress')))">
                a.lastLoginAddress,
            </if>
        </trim>
    </sql>
    <!-- 新增 区分主键自增加还是业务插入 -->
    <insert id="insert" parameterType="UserEntity" >
        insert into mortals_xhx_user
        (id,loginName,loginPwd,loginLimitAddress,realName,mobile,phone,email,qq,userType,siteIds,areaCodes,status,createTime,createUserId,createUserName,lastLoginTime,lastLoginAddress)
        VALUES
        (#{id},#{loginName},#{loginPwd},#{loginLimitAddress},#{realName},#{mobile},#{phone},#{email},#{qq},#{userType},#{siteIds},#{areaCodes},#{status},#{createTime},#{createUserId},#{createUserName},#{lastLoginTime},#{lastLoginAddress})
    </insert>

    <!-- 批量新增 -->
    <insert id="insertBatch" parameterType="paramDto">
        insert into mortals_xhx_user
        (id,loginName,loginPwd,loginLimitAddress,realName,mobile,phone,email,qq,userType,siteIds,areaCodes,status,createTime,createUserId,createUserName,lastLoginTime,lastLoginAddress)
        VALUES
        <foreach collection="data.dataList" item="item" index="index" separator="," >
            (#{item.id},#{item.loginName},#{item.loginPwd},#{item.loginLimitAddress},#{item.realName},#{item.mobile},#{item.phone},#{item.email},#{item.qq},#{item.userType},#{item.siteIds},#{item.areaCodes},#{item.status},#{item.createTime},#{item.createUserId},#{item.createUserName},#{item.lastLoginTime},#{item.lastLoginAddress})
        </foreach>
    </insert>


    <!-- 根据ParamDto更新 -->
    <update id="update" parameterType="paramDto">
        update mortals_xhx_user as a
        set
        <trim suffixOverrides="," suffix="">
            <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('loginPwd')) or (colPickMode==1 and !data.containsKey('loginPwd'))">
                a.loginPwd=#{data.loginPwd},
            </if>
            <if test="(colPickMode==0 and data.containsKey('loginLimitAddress')) or (colPickMode==1 and !data.containsKey('loginLimitAddress'))">
                a.loginLimitAddress=#{data.loginLimitAddress},
            </if>
            <if test="(colPickMode==0 and data.containsKey('realName')) or (colPickMode==1 and !data.containsKey('realName'))">
                a.realName=#{data.realName},
            </if>
            <if test="(colPickMode==0 and data.containsKey('mobile')) or (colPickMode==1 and !data.containsKey('mobile'))">
                a.mobile=#{data.mobile},
            </if>
            <if test="(colPickMode==0 and data.containsKey('phone')) or (colPickMode==1 and !data.containsKey('phone'))">
                a.phone=#{data.phone},
            </if>
            <if test="(colPickMode==0 and data.containsKey('email')) or (colPickMode==1 and !data.containsKey('email'))">
                a.email=#{data.email},
            </if>
            <if test="(colPickMode==0 and data.containsKey('qq')) or (colPickMode==1 and !data.containsKey('qq'))">
                a.qq=#{data.qq},
            </if>
            <if test="(colPickMode==0 and data.containsKey('userType')) or (colPickMode==1 and !data.containsKey('userType'))">
                a.userType=#{data.userType},
            </if>
            <if test="(colPickMode==0 and data.containsKey('userTypeIncrement')) or (colPickMode==1 and !data.containsKey('userTypeIncrement'))">
                a.userType=ifnull(a.userType,0) + #{data.userTypeIncrement},
            </if>
            <if test="(colPickMode==0 and data.containsKey('siteIds')) or (colPickMode==1 and !data.containsKey('siteIds'))">
                a.siteIds=#{data.siteIds},
            </if>
            <if test="(colPickMode==0 and data.containsKey('areaCodes')) or (colPickMode==1 and !data.containsKey('areaCodes'))">
                a.areaCodes=#{data.areaCodes},
            </if>
            <if test="(colPickMode==0 and data.containsKey('status')) or (colPickMode==1 and !data.containsKey('status'))">
                a.status=#{data.status},
            </if>
            <if test="(colPickMode==0 and data.containsKey('statusIncrement')) or (colPickMode==1 and !data.containsKey('statusIncrement'))">
                a.status=ifnull(a.status,0) + #{data.statusIncrement},
            </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('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('createUserName')) or (colPickMode==1 and !data.containsKey('createUserName'))">
                a.createUserName=#{data.createUserName},
            </if>
            <if test="(colPickMode==0 and data.containsKey('lastLoginTime')) or (colPickMode==1 and !data.containsKey('lastLoginTime'))">
                a.lastLoginTime=#{data.lastLoginTime},
            </if>
            <if test="(colPickMode==0 and data.containsKey('lastLoginAddress')) or (colPickMode==1 and !data.containsKey('lastLoginAddress'))">
                a.lastLoginAddress=#{data.lastLoginAddress},
            </if>
        </trim>
        <trim suffixOverrides="where" suffix="">
            where
            <trim prefixOverrides="and" prefix="">
                <include refid="_condition_"/>
            </trim>
        </trim>
    </update>
    <!-- 批量更新 -->
    <update id="updateBatch" parameterType="paramDto">
        update mortals_xhx_user as a
        <trim prefix="set" suffixOverrides=",">
            <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="loginPwd=(case" suffix="ELSE loginPwd end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('loginPwd')) or (colPickMode==1 and !item.containsKey('loginPwd'))">
                        when a.id=#{item.id} then #{item.loginPwd}
                    </if>
                </foreach>
            </trim>
            <trim prefix="loginLimitAddress=(case" suffix="ELSE loginLimitAddress end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('loginLimitAddress')) or (colPickMode==1 and !item.containsKey('loginLimitAddress'))">
                        when a.id=#{item.id} then #{item.loginLimitAddress}
                    </if>
                </foreach>
            </trim>
            <trim prefix="realName=(case" suffix="ELSE realName end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('realName')) or (colPickMode==1 and !item.containsKey('realName'))">
                        when a.id=#{item.id} then #{item.realName}
                    </if>
                </foreach>
            </trim>
            <trim prefix="mobile=(case" suffix="ELSE mobile end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('mobile')) or (colPickMode==1 and !item.containsKey('mobile'))">
                        when a.id=#{item.id} then #{item.mobile}
                    </if>
                </foreach>
            </trim>
            <trim prefix="phone=(case" suffix="ELSE phone end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('phone')) or (colPickMode==1 and !item.containsKey('phone'))">
                        when a.id=#{item.id} then #{item.phone}
                    </if>
                </foreach>
            </trim>
            <trim prefix="email=(case" suffix="ELSE email end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('email')) or (colPickMode==1 and !item.containsKey('email'))">
                        when a.id=#{item.id} then #{item.email}
                    </if>
                </foreach>
            </trim>
            <trim prefix="qq=(case" suffix="ELSE qq end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('qq')) or (colPickMode==1 and !item.containsKey('qq'))">
                        when a.id=#{item.id} then #{item.qq}
                    </if>
                </foreach>
            </trim>
            <trim prefix="userType=(case" suffix="ELSE userType end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <choose>
                        <when test="(colPickMode==0 and item.containsKey('userType')) or (colPickMode==1 and !item.containsKey('userType'))">
                            when a.id=#{item.id} then #{item.userType}
                        </when>
                        <when test="(colPickMode==0 and item.containsKey('userTypeIncrement')) or (colPickMode==1 and !item.containsKey('userTypeIncrement'))">
                            when a.id=#{item.id} then ifnull(a.userType,0) + #{item.userTypeIncrement}
                        </when>
                    </choose>
                </foreach>
            </trim>
            <trim prefix="siteIds=(case" suffix="ELSE siteIds end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('siteIds')) or (colPickMode==1 and !item.containsKey('siteIds'))">
                        when a.id=#{item.id} then #{item.siteIds}
                    </if>
                </foreach>
            </trim>
            <trim prefix="areaCodes=(case" suffix="ELSE areaCodes end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('areaCodes')) or (colPickMode==1 and !item.containsKey('areaCodes'))">
                        when a.id=#{item.id} then #{item.areaCodes}
                    </if>
                </foreach>
            </trim>
            <trim prefix="status=(case" suffix="ELSE status end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <choose>
                        <when test="(colPickMode==0 and item.containsKey('status')) or (colPickMode==1 and !item.containsKey('status'))">
                            when a.id=#{item.id} then #{item.status}
                        </when>
                        <when test="(colPickMode==0 and item.containsKey('statusIncrement')) or (colPickMode==1 and !item.containsKey('statusIncrement'))">
                            when a.id=#{item.id} then ifnull(a.status,0) + #{item.statusIncrement}
                        </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="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="createUserName=(case" suffix="ELSE createUserName end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('createUserName')) or (colPickMode==1 and !item.containsKey('createUserName'))">
                        when a.id=#{item.id} then #{item.createUserName}
                    </if>
                </foreach>
            </trim>
            <trim prefix="lastLoginTime=(case" suffix="ELSE lastLoginTime end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('lastLoginTime')) or (colPickMode==1 and !item.containsKey('lastLoginTime'))">
                        when a.id=#{item.id} then #{item.lastLoginTime}
                    </if>
                </foreach>
            </trim>
            <trim prefix="lastLoginAddress=(case" suffix="ELSE lastLoginAddress end),">
                <foreach collection="data.dataList" item="item" index="index" separator="" >
                    <if test="(colPickMode==0 and item.containsKey('lastLoginAddress')) or (colPickMode==1 and !item.containsKey('lastLoginAddress'))">
                        when a.id=#{item.id} then #{item.lastLoginAddress}
                    </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="UserEntity-Map">
        select <include refid="_columns"/>
        from mortals_xhx_user as a
        where a.id=#{condition.id}
    </select>
    <!-- 根据主健删除 -->
    <delete id="deleteByKey" parameterType="paramDto">
        delete a.* from mortals_xhx_user as a where a.id=#{condition.id}
    </delete>
    <!-- 根据主健删除一批，针对单一主健有效 -->
    <delete id="deleteByKeys">
        delete from mortals_xhx_user 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 mortals_xhx_user as a
        <trim suffixOverrides="where" suffix="">
            where
            <trim prefixOverrides="and" prefix="">
                <include refid="_condition_"/>
            </trim>
        </trim>
    </delete>
    <!-- 获取列表 -->
    <select id="getList" parameterType="paramDto" resultMap="UserEntity-Map">
        select <include refid="_columns"/>
        from mortals_xhx_user 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 mortals_xhx_user 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('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('loginPwd')">
            <if test="conditionParamRef.loginPwd != null and conditionParamRef.loginPwd != ''">
                ${_conditionType_} a.loginPwd like #{${_conditionParam_}.loginPwd}
            </if>
            <if test="conditionParamRef.loginPwd == null">
                ${_conditionType_} a.loginPwd is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('loginPwdList')">
            ${_conditionType_} a.loginPwd in
            <foreach collection="conditionParamRef.loginPwdList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>

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

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

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

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

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

        <if test="conditionParamRef.containsKey('qq')">
            <if test="conditionParamRef.qq != null and conditionParamRef.qq != ''">
                ${_conditionType_} a.qq like #{${_conditionParam_}.qq}
            </if>
            <if test="conditionParamRef.qq == null">
                ${_conditionType_} a.qq is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('qqList')">
            ${_conditionType_} a.qq in
            <foreach collection="conditionParamRef.qqList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="conditionParamRef.containsKey('userType')">
            <if test="conditionParamRef.userType != null ">
                ${_conditionType_} a.userType = #{${_conditionParam_}.userType}
            </if>
            <if test="conditionParamRef.userType == null">
                ${_conditionType_} a.userType is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('userTypeList')">
            ${_conditionType_} a.userType in
            <foreach collection="conditionParamRef.userTypeList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="conditionParamRef.containsKey('userTypeStart') and conditionParamRef.userTypeStart != null">
            ${_conditionType_} a.userType <![CDATA[ >= ]]> #{${_conditionParam_}.userTypeStart}
        </if>
        <if test="conditionParamRef.containsKey('userTypeEnd') and conditionParamRef.userTypeEnd != null">
            ${_conditionType_} a.userType <![CDATA[ <= ]]> #{${_conditionParam_}.userTypeEnd}
        </if>


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

        <if test="conditionParamRef.containsKey('areaCodes')">
            <if test="conditionParamRef.areaCodes != null and conditionParamRef.areaCodes != ''">
                ${_conditionType_} a.areaCodes like #{${_conditionParam_}.areaCodes}
            </if>
            <if test="conditionParamRef.areaCodes == null">
                ${_conditionType_} a.areaCodes is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('areaCodesList')">
            ${_conditionType_} a.areaCodes in
            <foreach collection="conditionParamRef.areaCodesList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="conditionParamRef.containsKey('status')">
            <if test="conditionParamRef.status != null ">
                ${_conditionType_} a.status = #{${_conditionParam_}.status}
            </if>
            <if test="conditionParamRef.status == null">
                ${_conditionType_} a.status is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('statusList')">
            ${_conditionType_} a.status in
            <foreach collection="conditionParamRef.statusList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="conditionParamRef.containsKey('statusStart') and conditionParamRef.statusStart != null">
            ${_conditionType_} a.status <![CDATA[ >= ]]> #{${_conditionParam_}.statusStart}
        </if>
        <if test="conditionParamRef.containsKey('statusEnd') and conditionParamRef.statusEnd != null">
            ${_conditionType_} a.status <![CDATA[ <= ]]> #{${_conditionParam_}.statusEnd}
        </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('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('createUserName')">
            <if test="conditionParamRef.createUserName != null and conditionParamRef.createUserName != ''">
                ${_conditionType_} a.createUserName like #{${_conditionParam_}.createUserName}
            </if>
            <if test="conditionParamRef.createUserName == null">
                ${_conditionType_} a.createUserName is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('createUserNameList')">
            ${_conditionType_} a.createUserName in
            <foreach collection="conditionParamRef.createUserNameList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>

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

        <if test="conditionParamRef.containsKey('lastLoginAddress')">
            <if test="conditionParamRef.lastLoginAddress != null and conditionParamRef.lastLoginAddress != ''">
                ${_conditionType_} a.lastLoginAddress like #{${_conditionParam_}.lastLoginAddress}
            </if>
            <if test="conditionParamRef.lastLoginAddress == null">
                ${_conditionType_} a.lastLoginAddress is null
            </if>
        </if>
        <if test="conditionParamRef.containsKey('lastLoginAddressList')">
            ${_conditionType_} a.lastLoginAddress in
            <foreach collection="conditionParamRef.lastLoginAddressList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </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('loginName')">
                    a.loginName
                    <if test='orderCol.loginName != null and "DESC".equalsIgnoreCase(orderCol.loginName)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('loginPwd')">
                    a.loginPwd
                    <if test='orderCol.loginPwd != null and "DESC".equalsIgnoreCase(orderCol.loginPwd)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('loginLimitAddress')">
                    a.loginLimitAddress
                    <if test='orderCol.loginLimitAddress != null and "DESC".equalsIgnoreCase(orderCol.loginLimitAddress)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('realName')">
                    a.realName
                    <if test='orderCol.realName != null and "DESC".equalsIgnoreCase(orderCol.realName)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('mobile')">
                    a.mobile
                    <if test='orderCol.mobile != null and "DESC".equalsIgnoreCase(orderCol.mobile)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('phone')">
                    a.phone
                    <if test='orderCol.phone != null and "DESC".equalsIgnoreCase(orderCol.phone)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('email')">
                    a.email
                    <if test='orderCol.email != null and "DESC".equalsIgnoreCase(orderCol.email)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('qq')">
                    a.qq
                    <if test='orderCol.qq != null and "DESC".equalsIgnoreCase(orderCol.qq)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('userType')">
                    a.userType
                    <if test='orderCol.userType != null and "DESC".equalsIgnoreCase(orderCol.userType)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('siteIds')">
                    a.siteIds
                    <if test='orderCol.siteIds != null and "DESC".equalsIgnoreCase(orderCol.siteIds)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('areaCodes')">
                    a.areaCodes
                    <if test='orderCol.areaCodes != null and "DESC".equalsIgnoreCase(orderCol.areaCodes)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('status')">
                    a.status
                    <if test='orderCol.status != null and "DESC".equalsIgnoreCase(orderCol.status)'>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('createUserId')">
                    a.createUserId
                    <if test='orderCol.createUserId != null and "DESC".equalsIgnoreCase(orderCol.createUserId)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('createUserName')">
                    a.createUserName
                    <if test='orderCol.createUserName != null and "DESC".equalsIgnoreCase(orderCol.createUserName)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('lastLoginTime')">
                    a.lastLoginTime
                    <if test='orderCol.lastLoginTime != null and "DESC".equalsIgnoreCase(orderCol.lastLoginTime)'>DESC</if>
                    ,
                </if>
                <if test="orderCol.containsKey('lastLoginAddress')">
                    a.lastLoginAddress
                    <if test='orderCol.lastLoginAddress != null and "DESC".equalsIgnoreCase(orderCol.lastLoginAddress)'>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>