diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDataScopeServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDataScopeServiceImpl.java index 47c5528e..d2c5d5cb 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDataScopeServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDataScopeServiceImpl.java @@ -44,11 +44,14 @@ public class SysDataScopeServiceImpl implements ISysDataScopeService { @Override public String getDeptAndChild(Long deptId) { - List list = deptMapper.selectList(new LambdaQueryWrapper() + List deptList = deptMapper.selectList(new LambdaQueryWrapper() .select(SysDept::getDeptId) - .eq(SysDept::getDeptId, deptId) - .or() .apply(DataBaseHelper.findInSet(deptId, "ancestors"))); + List ids = deptList.stream().map(SysDept::getDeptId).collect(Collectors.toList()); + ids.add(deptId); + List list = deptMapper.selectList(new LambdaQueryWrapper() + .select(SysDept::getDeptId) + .in(SysDept::getDeptId, ids)); if (CollUtil.isNotEmpty(list)) { return list.stream().map(d -> Convert.toStr(d.getDeptId())).collect(Collectors.joining(",")); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index e5b54aba..09c5ba2c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -82,9 +82,9 @@ public class SysUserServiceImpl implements ISysUserService { List deptList = deptMapper.selectList(new LambdaQueryWrapper() .select(SysDept::getDeptId) .apply(DataBaseHelper.findInSet(user.getDeptId(), "ancestors"))); - w.eq("u.dept_id", user.getDeptId()) - .or() - .in("u.dept_id", deptList.stream().map(SysDept::getDeptId).collect(Collectors.toList())); + List ids = deptList.stream().map(SysDept::getDeptId).collect(Collectors.toList()); + ids.add(user.getDeptId()); + w.in("u.dept_id", ids); }); return wrapper; }