IamSysUser.xml 7.09 KB
Newer Older
Rensq's avatar
Rensq committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.testor.module.iam.dao.IamSysUserDao">
    <!-- 开启二级缓存 -->
    <!-- <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/> -->
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.testor.module.iam.model.domain.IamSysUser">
        <id column="id" property="id"/>
        <id column="user_id" property="userId"/>
        <id column="mobile" property="mobile"/>
        <id column="name" property="name"/>
        <id column="main_department" property="mainDepartment"/>
        <id column="email" property="email"/>
        <id column="gender" property="gender"/>
        <id column="enable" property="enable"/>
        <id column="ad_account" property="adAccount"/>
        <id column="telephone" property="telephone"/>
        <id column="polity" property="polity"/>
        <id column="id_type" property="idType"/>
        <id column="id_card" property="idCard"/>
        <id column="level_code" property="levelCode"/>
        <id column="level_name" property="levelName"/>
        <id column="psn_cl" property="psnCl"/>
    </resultMap>

    <select id="querySysUserList" resultType="com.testor.module.sys.model.dto.SysUserListResponse">
        SELECT
            u.user_id,u.org_id,u.login_name,u.user_name,u.user_type,u.photo_url,u.sex,u.address,
            u.zip_code,u.phone_no,u.fax,u.email,u.status,u.org_name,u.age,u.dept_id,i.iam_user_id
        FROM t_sys_user u
        LEFT JOIN iam_user_mapping i ON u.user_id = i.user_id
        <where>
            <if test="param.loginName != null and param.loginName !='' ">
                and u.login_name like concat('%',#{param.loginName},'%')
            </if>
            <if test="param.userName != null and param.userName !='' ">
                and u.user_name like concat('%',#{param.userName},'%')
            </if>
            <if test="param.phoneNo != null and param.phoneNo !='' ">
                and u.phone_no like concat('%',#{param.userName},'%')
            </if>
            <if test="param.userType != null and param.userType !='' ">
                and u.user_type = #{param.userType}
            </if>
            <if test="param.orgIdList != null">
                and u.org_id in
                <foreach collection="param.orgIdList" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="param.statusList != null">
                and u.status in
                <foreach collection="param.statusList" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="param.iamUserId != null and param.iamUserId !='' ">
                and i.iam_user_id like concat('%',#{param.iamUserId},'%')
            </if>
            <if test="param.orderBy != null and param.orderBy !='' ">
                ORDER BY concat(#{param.orderBy},' ',#{param.orderBy})
            </if>
        </where>
        <if test="param.limit!=null and param.limit!=''">
            LIMIT #{param.limit} OFFSET #{param.offset}
        </if>
    </select>

    <select id="querySysUserListCount" resultType="java.lang.Long">
        SELECT
        count(u.user_id)
        FROM t_sys_user u
        LEFT JOIN iam_user_mapping i ON u.user_id = i.user_id
        <where>
            <if test="param.loginName != null and param.loginName !='' ">
                and u.login_name like concat('%',#{param.loginName},'%')
            </if>
            <if test="param.userName != null and param.userName !='' ">
                and u.user_name like concat('%',#{param.userName},'%')
            </if>
            <if test="param.phoneNo != null and param.phoneNo !='' ">
                and u.phone_no like concat('%',#{param.userName},'%')
            </if>
            <if test="param.userType != null and param.userType !='' ">
                and u.user_type = #{param.userType}
            </if>
            <if test="param.iamUserId != null and param.iamUserId !='' ">
                and i.iam_user_id like concat('%',#{param.iamUserId},'%')
            </if>
            <if test="param.orgIdList != null">
                and u.org_id in
                <foreach collection="param.orgIdList" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="param.statusList != null">
                and u.status in
                <foreach collection="param.statusList" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>

    <select id="pageUserList" resultType="com.testor.module.sys.model.dto.SysUserListResponse">
        SELECT
        u.user_id,
        u.org_id,
        u.login_name,
        u.user_name,
        u.user_type,
        ue.user_type_code,
        u.photo_url,
        u.sex,
        u.address,
        u.zip_code,
        u.phone_no,
        u.fax,
        u.email,
        u.STATUS,
        so.org_name,
        u.age,
        u.dept_id,
        d.org_name AS deptName,
        i.iam_user_id
        FROM
        t_sys_user u
        LEFT JOIN iam_user_mapping i ON u.user_id = i.user_id
        LEFT JOIN t_sys_org so ON so.org_id = u.org_id AND so.is_dept = 0
        LEFT JOIN t_sys_org d ON d.org_id = u.dept_id AND d.is_dept = 1
        LEFT JOIN t_sys_user_extend ue ON u.user_id = ue.user_id
        <where>
            u.STATUS != '1'
            <if test="param.loginName != null and param.loginName !='' ">
                and u.login_name like concat('%',#{param.loginName},'%')
            </if>
            <if test="param.userName != null and param.userName !='' ">
                and u.user_name like concat('%',#{param.userName},'%')
            </if>
            <if test="param.phoneNo != null and param.phoneNo !='' ">
                and u.phone_no like concat('%',#{param.phoneNo},'%')
            </if>
            <if test="param.userType != null and param.userType !='' ">
                and u.user_type = #{param.userType}
            </if>
            <if test="param.orgIdList != null">
                and u.org_id in
                <foreach collection="param.orgIdList" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="param.statusList != null">
                and u.status in
                <foreach collection="param.statusList" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="param.iamUserId != null and param.iamUserId !='' ">
                and i.iam_user_id like concat('%',#{param.iamUserId},'%')
            </if>
            <if test="param.orderBy != null and param.orderBy !='' ">
                ORDER BY concat(#{param.orderBy},' ',#{param.orderType})
            </if>
        </where>
    </select>
</mapper>