<?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="org.jeecg.modules.system.mapper.SysUserRoleMapper">
|
<select id="getUsersByRoles" resultType="org.jeecg.modules.system.entity.SysUser">
|
select t.* from sys_user t where t.del_flag = 0
|
and t.id in (
|
select t1.user_id from sys_user_role t1
|
left join sys_role t2 on t1.role_id = t2.id
|
<if test="roleList!=null and roleList.size()>0">
|
and t2.role_code in
|
<foreach collection="roleList" index="index" item="roleCode" open="(" separator="," close=")">
|
#{roleCode}
|
</foreach>
|
</if>
|
where t2.id is not null
|
)
|
</select>
|
|
<select id="queryRoleNamesByUserIds" resultType="org.jeecg.modules.system.vo.SysUserRoleExitVo">
|
SELECT
|
t1.username,
|
ISNULL(
|
STUFF(
|
(
|
SELECT ',' + t3.role_name
|
FROM sys_user_role t2
|
INNER JOIN sys_role t3 ON t2.role_id = t3.id
|
WHERE t2.user_id = t1.id
|
FOR XML PATH(''), TYPE
|
).value('.', 'NVARCHAR(MAX)'), 1, 1, ''
|
), ''
|
) AS roleNames
|
FROM sys_user t1
|
<where>
|
<if test="userIds!=null and userIds.size()>0">
|
AND t1.id IN
|
<foreach collection="userIds" index="index" item="userId" open="(" separator="," close=")">
|
#{userId}
|
</foreach>
|
</if>
|
</where>
|
GROUP BY t1.username, t1.id
|
</select>
|
</mapper>
|