feat: 全量提交
This commit is contained in:
142
src/main/resources/mapper/SysUserMapper.xml
Normal file
142
src/main/resources/mapper/SysUserMapper.xml
Normal file
@@ -0,0 +1,142 @@
|
||||
<?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.youlai.system.mapper.SysUserMapper">
|
||||
|
||||
<!-- 用户分页列表 -->
|
||||
<select id="listUserPages" resultType="com.youlai.system.pojo.po.UserPO">
|
||||
SELECT
|
||||
u.id,
|
||||
u.username,
|
||||
u.nickname,
|
||||
u.mobile,
|
||||
u.gender,
|
||||
u.avatar,
|
||||
u.STATUS,
|
||||
d.NAME AS dept_name,
|
||||
GROUP_CONCAT( r.NAME ) AS roleNames,
|
||||
u.create_time
|
||||
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 ur.role_id = r.id
|
||||
<where>
|
||||
u.deleted = 0
|
||||
<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>
|
||||
</where>
|
||||
GROUP BY u.id
|
||||
</select>
|
||||
|
||||
<!-- 用户表单信息映射 -->
|
||||
<resultMap id="UserFormMap" type="com.youlai.system.pojo.po.UserFormPO">
|
||||
<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.youlai.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,
|
||||
dept_id
|
||||
FROM sys_user
|
||||
WHERE id = #{userId}
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<!-- 用户认证信息映射 -->
|
||||
<resultMap id="UserAuthMap" type="com.youlai.system.pojo.po.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.youlai.system.pojo.vo.user.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
|
||||
<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>
|
||||
Reference in New Issue
Block a user