refactor(system): 优化数据权限查询效率
- 重构了 LogInstanceMapper.xml 文件中的数据权限查询逻辑 - 使用 flag 字段进行部门权限判断,提高了查询效率- 移除了复杂的递归查询,简化了 SQL 结构
This commit is contained in:
parent
155f31a23c
commit
866dd70f53
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user