123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- <?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.qmrb.system.mapper.SysUserMapper">
- <!-- 用户分页列表 -->
- <select id="getUserPage" resultType="com.qmrb.system.pojo.bo.UserBO">
- SELECT
- u.id,
- u.username,
- u.nickname,
- u.mobile,
- u.gender,
- u.avatar,
- u.STATUS,
- u.user_type,
- d.NAME AS dept_name,
- GROUP_CONCAT( r.NAME ) AS roleNames,
- u.create_time,
- b.name as levelName
- FROM
- sys_user u
- LEFT JOIN sys_dept d ON u.dept_id = d.id
- LEFT JOIN sys_user_role sur ON u.id = sur.user_id
- LEFT JOIN sys_role r ON sur.role_id = r.id
- left join sys_dict b on b.type_code='doctor_level' and u.level_name=b.value
- <where>
- u.deleted = 0 AND u.username != 'root'
- <if test='queryParams.keywords!=null and queryParams.keywords.trim() neq ""'>
- AND (
- u.username LIKE CONCAT('%',#{queryParams.keywords},'%')
- OR u.nickname LIKE CONCAT('%',#{queryParams.keywords},'%')
- OR u.mobile LIKE CONCAT('%',#{queryParams.keywords},'%')
- )
- </if>
- <if test='queryParams.status!=null'>
- AND u.status = #{queryParams.status}
- </if>
- <if test='queryParams.deptId!=null'>
- AND concat(',',concat(d.tree_path,',',d.id),',') like concat('%,',#{queryParams.deptId},',%')
- </if>
- <if test='queryParams.userType!=null and queryParams.userType.trim() neq ""'>
- AND u.user_type = #{queryParams.userType}
- </if>
- </where>
- GROUP BY u.id,b.name
- </select>
- <!-- 用户表单信息映射 -->
- <resultMap id="UserFormMap" type="com.qmrb.system.pojo.bo.UserFormBO">
- <id property="id" column="id" jdbcType="BIGINT"/>
- <result property="username" column="username" jdbcType="VARCHAR"/>
- <result property="nickname" column="nickname" jdbcType="VARCHAR"/>
- <result property="mobile" column="mobile" jdbcType="VARCHAR"/>
- <result property="gender" column="gender" jdbcType="TINYINT"/>
- <result property="avatar" column="avatar" jdbcType="VARCHAR"/>
- <result property="email" column="email" jdbcType="VARCHAR"/>
- <result property="status" column="status" jdbcType="BOOLEAN"/>
- <result property="deptId" column="dept_id" jdbcType="BIGINT"></result>
- <collection
- property="roleIds"
- column="id"
- select="com.qmrb.system.mapper.SysUserRoleMapper.listRoleIdsByUserId" >
- <result column="role_id" />
- </collection>
- </resultMap>
- <!-- 根据用户ID获取用户详情 -->
- <select id="getUserDetail" resultMap="UserFormMap">
- SELECT id,
- username,
- nickname,
- mobile,
- gender,
- avatar,
- email,
- STATUS,
- user_type,
- dept_id
- FROM sys_user
- WHERE id = #{userId}
- AND deleted = 0
- </select>
- <!-- 用户认证信息映射 -->
- <resultMap id="UserAuthMap" type="com.qmrb.system.pojo.bo.UserAuthInfo">
- <id property="userId" column="userId" jdbcType="BIGINT"/>
- <result property="username" column="username" jdbcType="VARCHAR"/>
- <result property="password" column="password" jdbcType="VARCHAR"/>
- <result property="status" column="status" jdbcType="BOOLEAN"/>
- <result property="deptId" column="dept_id" jdbcType="BIGINT"></result>
- <collection property="roles" ofType="string" javaType="java.util.Set">
- <result column="code"></result>
- </collection>
- </resultMap>
- <!-- 根据用户名获取认证信息 -->
- <select id="getUserAuthInfo" resultMap="UserAuthMap">
- SELECT
- t1.id userId,
- t1.username,
- t1.nickname,
- t1.PASSWORD,
- t1.STATUS,
- t1.dept_id ,
- t3.CODE
- FROM
- sys_user t1
- LEFT JOIN sys_user_role t2 ON t2.user_id = t1.id
- LEFT JOIN sys_role t3 ON t3.id = t2.role_id
- WHERE
- t1.username = #{username} AND t1.deleted=0
- </select>
- <!-- 获取用户导出列表 -->
- <select id="listExportUsers" resultType="com.qmrb.system.pojo.vo.UserExportVO">
- SELECT
- u.username,
- u.nickname,
- u.mobile,
- CASE u.gender
- WHEN 1 THEN '男'
- WHEN 2 THEN '女'
- ELSE '未知'
- END gender,
- d.NAME AS dept_name,
- u.create_time
- FROM
- sys_user u
- LEFT JOIN sys_dept d ON u.dept_id = d.id
- <where>
- u.deleted = 0 AND u.username != 'root'
- <if test='keywords!=null and keywords.trim() neq ""'>
- AND (u.username LIKE CONCAT('%',#{keywords},'%')
- OR u.nickname LIKE CONCAT('%',#{keywords},'%')
- OR u.mobile LIKE CONCAT('%',#{keywords},'%'))
- </if>
- <if test='status!=null'>
- AND u.status = #{status}
- </if>
- <if test='deptId!=null'>
- AND concat(',',concat(d.tree_path,',',d.id),',') like concat('%,',#{deptId},',%')
- </if>
- </where>
- GROUP BY u.id
- </select>
- </mapper>
|