From e480f616e055e9fdfdb1bac38de9b01ddbcca476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Mon, 14 Mar 2022 15:58:27 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BD=BF=E7=94=A8=20in=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20or=20=E6=8F=90=E5=8D=87=E7=B4=A2=E5=BC=95=E5=91=BD?= =?UTF-8?q?=E4=B8=AD=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/impl/SysDataScopeServiceImpl.java | 9 ++++++--- .../ruoyi/system/service/impl/SysUserServiceImpl.java | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) 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; }