From 7f97a5eabc3ef039719e05d0b7ac7594d9ba9c39 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期四, 06 二月 2025 18:24:35 +0800
Subject: [PATCH] 系统设置(除开人员管理)

---
 ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml |   25 +++++++++++++++++--------
 1 files changed, 17 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..f24c54f 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">

--
Gitblit v1.7.1