From a8de81aba7aaea25125ef25646aaddf5cba370ed 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: Thu, 7 Nov 2024 15:51:10 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E5=B0=81?= =?UTF-8?q?=E8=A3=85=E9=83=A8=E9=97=A8=E5=9F=BA=E4=BA=8E=E7=88=B6id?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dromara/system/dubbo/RemoteDataScopeServiceImpl.java | 4 +--- .../java/org/dromara/system/mapper/SysDeptMapper.java | 8 ++++++++ .../dromara/system/service/impl/SysPostServiceImpl.java | 8 ++------ .../dromara/system/service/impl/SysUserServiceImpl.java | 4 +--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteDataScopeServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteDataScopeServiceImpl.java index c26111a6..a07e2011 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteDataScopeServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteDataScopeServiceImpl.java @@ -65,9 +65,7 @@ public class RemoteDataScopeServiceImpl implements RemoteDataScopeService { if (ObjectUtil.isNull(deptId)) { return "-1"; } - List deptList = deptMapper.selectList(new LambdaQueryWrapper() - .select(SysDept::getDeptId) - .apply(DataBaseHelper.findInSet(deptId, "ancestors"))); + List deptList = deptMapper.selectListByParentId(deptId); List ids = StreamUtils.toList(deptList, SysDept::getDeptId); ids.add(deptId); if (CollUtil.isNotEmpty(ids)) { diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysDeptMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysDeptMapper.java index 08dda662..048d2fa4 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysDeptMapper.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysDeptMapper.java @@ -1,10 +1,12 @@ package org.dromara.system.mapper; import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Constants; import org.dromara.common.mybatis.annotation.DataColumn; import org.dromara.common.mybatis.annotation.DataPermission; import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; +import org.dromara.common.mybatis.helper.DataBaseHelper; import org.dromara.system.domain.SysDept; import org.dromara.system.domain.vo.SysDeptVo; import org.apache.ibatis.annotations.Param; @@ -34,6 +36,12 @@ public interface SysDeptMapper extends BaseMapperPlus { }) long countDeptById(Long deptId); + default List selectListByParentId(Long parentId) { + return this.selectList(new LambdaQueryWrapper() + .select(SysDept::getDeptId) + .apply(DataBaseHelper.findInSet(parentId, "ancestors"))); + } + /** * 根据角色ID查询部门树信息 * diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysPostServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysPostServiceImpl.java index 2c38129a..d616a50d 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysPostServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysPostServiceImpl.java @@ -78,12 +78,8 @@ public class SysPostServiceImpl implements ISysPostService { } else if (ObjectUtil.isNotNull(bo.getBelongDeptId())) { //部门树搜索 wrapper.and(x -> { - List deptIds = deptMapper.selectList(new LambdaQueryWrapper() - .select(SysDept::getDeptId) - .apply(DataBaseHelper.findInSet(bo.getBelongDeptId(), "ancestors"))) - .stream() - .map(SysDept::getDeptId) - .collect(Collectors.toList()); + List deptList = deptMapper.selectListByParentId(bo.getBelongDeptId()); + List deptIds = StreamUtils.toList(deptList, SysDept::getDeptId); deptIds.add(bo.getBelongDeptId()); x.in(SysPost::getDeptId, deptIds); }); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java index bacf9ebf..a43e6738 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java @@ -85,9 +85,7 @@ public class SysUserServiceImpl implements ISysUserService { .between(params.get("beginTime") != null && params.get("endTime") != null, "u.create_time", params.get("beginTime"), params.get("endTime")) .and(ObjectUtil.isNotNull(user.getDeptId()), w -> { - List deptList = deptMapper.selectList(new LambdaQueryWrapper() - .select(SysDept::getDeptId) - .apply(DataBaseHelper.findInSet(user.getDeptId(), "ancestors"))); + List deptList = deptMapper.selectListByParentId(user.getDeptId()); List ids = StreamUtils.toList(deptList, SysDept::getDeptId); ids.add(user.getDeptId()); w.in("u.dept_id", ids);