From 5fa6e6f8410ef9d057174bcff2a3c5038c54a551 Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期日, 27 四月 2025 18:41:20 +0800 Subject: [PATCH] bug修改 --- ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml | 36 ++++++++++++++++++++++++++++-------- 1 files changed, 28 insertions(+), 8 deletions(-) diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml index c05f6fc..f3dfeeb 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml @@ -95,19 +95,28 @@ AND del_flag = 0 </where> </select> - <select id="selectList" resultType="com.ruoyi.common.core.domain.entity.SysRole"> - select role_id AS roleId, role_name AS roleName, role_key AS roleKey, role_sort AS roleSort, data_scope AS dataScope, - menu_check_strictly AS menuCheckStrictly, dept_check_strictly AS deptCheckStrictly,status AS status, del_flag AS delFlag, - create_time AS createTime,create_by AS createBy,postType AS postType,removeDays AS removeDays - from sys_role + <select id="selectPageList" resultType="com.ruoyi.common.core.domain.entity.SysRole"> + select a.role_id AS roleId, a.role_name AS roleName, a.role_key AS roleKey, a.role_sort AS roleSort, a.data_scope AS dataScope, + a.menu_check_strictly AS menuCheckStrictly, a.dept_check_strictly AS deptCheckStrictly,a.status AS status, a.del_flag AS delFlag, + a.create_time AS createTime,a.create_by AS createBy,a.postType AS postType,a.removeDays AS removeDays, + IFNULL(b.userCount,0) as userCount + from sys_role a + LEFT JOIN + (SELECT + r.role_id AS roleId, + COUNT(ur.user_id) AS userCount + FROM sys_role r + LEFT JOIN sys_user_role ur ON r.role_id = ur.role_id + where r.del_flag = 0 + GROUP BY r.role_id) b on a.role_id = b.roleId <where> <if test="query.roleName != null and query.roleName != ''"> - AND role_name LIKE concat('%',#{query.roleName},'%') + AND a.role_name LIKE concat('%',#{query.roleName},'%') </if> <if test="query.status != null"> - AND status = #{query.status} + AND a.status = #{query.status} </if> - AND del_flag = 0 + AND a.del_flag = 0 </where> </select> <select id="selectCount" resultType="java.lang.Integer"> @@ -139,6 +148,17 @@ left join sys_role t2 on t1.role_id = t2.role_id where t1.user_id = #{userId} </select> + <select id="selectRoleByUserIds" resultType="com.ruoyi.common.core.domain.entity.SysRole"> + select + a.user_id as role_id, + b.nick_name as role_name + from sys_user_role a + left join sys_user b on a.user_id = b.user_id + where a.role_id in + <foreach item="item" index="index" collection="roleIds" open="(" separator="," close=")"> + #{item} + </foreach> + </select> <insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId"> insert into sys_role( -- Gitblit v1.7.1