From 866dd70f5337b07d6bc3bcfa8e936d24b3b6e56a Mon Sep 17 00:00:00 2001 From: furongxin <419481438@qq.com> Date: Sat, 5 Jul 2025 13:01:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor(system):=20=E4=BC=98=E5=8C=96=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9D=83=E9=99=90=E6=9F=A5=E8=AF=A2=E6=95=88=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 重构了 LogInstanceMapper.xml 文件中的数据权限查询逻辑 - 使用 flag 字段进行部门权限判断,提高了查询效率- 移除了复杂的递归查询,简化了 SQL 结构 --- .../mapper/worklog/LogInstanceMapper.xml | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/worklog/LogInstanceMapper.xml b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/worklog/LogInstanceMapper.xml index b87791c9..680a423e 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/worklog/LogInstanceMapper.xml +++ b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/worklog/LogInstanceMapper.xml @@ -31,22 +31,18 @@ WHEN 4 THEN ( - SELECT - GROUP_CONCAT( id SEPARATOR ', ' ) AS ids - FROM - ( - SELECT - t1.id, - t1.NAME, - IF - ( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild - FROM - ( SELECT id, parent_id, NAME FROM system_dept t ORDER BY parent_id, id ) t1, - ( SELECT @pids := user.dept_id ) t2 - ) t3 - WHERE - ischild != 0 - OR id = user.dept_id + SELECT + GROUP_CONCAT( t2.id SEPARATOR ', ' ) AS ids + FROM + ( + SELECT t1.id + FROM + system_dept t1 + WHERE + t1.flag LIKE CONCAT('%-', USER.dept_id) + OR t1.flag LIKE CONCAT(USER.dept_id, '-%') + OR t1.flag LIKE CONCAT('%-', USER.dept_id, '-%') + ) t2 ) -- read_user.data_scope_dept_ids -- 本部门及以下数据权限 END AS ids