Pre Merge pull request !706 from AprilWind/dev-dept

This commit is contained in:
AprilWind 2025-06-27 02:14:24 +00:00 committed by Gitee
commit 412f0dd89d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 10 additions and 16 deletions

View File

@ -29,6 +29,7 @@ import org.dromara.system.domain.vo.SysDeptVo;
import org.dromara.system.mapper.SysDeptMapper;
import org.dromara.system.mapper.SysRoleMapper;
import org.dromara.system.mapper.SysUserMapper;
import org.dromara.system.service.ISysDataScopeService;
import org.dromara.system.service.ISysDeptService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
@ -110,11 +111,8 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
//部门树搜索
lqw.and(x -> {
Long parentId = bo.getBelongDeptId();
List<SysDept> deptList = baseMapper.selectListByParentId(parentId);
List<Long> deptIds = StreamUtils.toList(deptList, SysDept::getDeptId);
deptIds.add(parentId);
x.in(SysDept::getDeptId, deptIds);
String deptIds = SpringUtils.getBean(ISysDataScopeService.class).getDeptAndChild(bo.getBelongDeptId());
x.in(SysDept::getDeptId, StringUtils.splitList(deptIds));
});
}
return lqw;

View File

@ -10,18 +10,18 @@ import org.dromara.common.core.constant.SystemConstants;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.service.PostService;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.SpringUtils;
import org.dromara.common.core.utils.StreamUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.system.domain.SysDept;
import org.dromara.system.domain.SysPost;
import org.dromara.system.domain.SysUserPost;
import org.dromara.system.domain.bo.SysPostBo;
import org.dromara.system.domain.vo.SysPostVo;
import org.dromara.system.mapper.SysDeptMapper;
import org.dromara.system.mapper.SysPostMapper;
import org.dromara.system.mapper.SysUserPostMapper;
import org.dromara.system.service.ISysDataScopeService;
import org.dromara.system.service.ISysPostService;
import org.springframework.stereotype.Service;
@ -39,7 +39,6 @@ import java.util.Map;
public class SysPostServiceImpl implements ISysPostService, PostService {
private final SysPostMapper baseMapper;
private final SysDeptMapper deptMapper;
private final SysUserPostMapper userPostMapper;
@Override
@ -92,10 +91,8 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
} else if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
//部门树搜索
wrapper.and(x -> {
List<SysDept> deptList = deptMapper.selectListByParentId(bo.getBelongDeptId());
List<Long> deptIds = StreamUtils.toList(deptList, SysDept::getDeptId);
deptIds.add(bo.getBelongDeptId());
x.in(SysPost::getDeptId, deptIds);
String deptIds = SpringUtils.getBean(ISysDataScopeService.class).getDeptAndChild(bo.getBelongDeptId());
x.in(SysPost::getDeptId, StringUtils.splitList(deptIds));
});
}
return wrapper;

View File

@ -29,6 +29,7 @@ import org.dromara.system.domain.vo.SysRoleVo;
import org.dromara.system.domain.vo.SysUserExportVo;
import org.dromara.system.domain.vo.SysUserVo;
import org.dromara.system.mapper.*;
import org.dromara.system.service.ISysDataScopeService;
import org.dromara.system.service.ISysUserService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
@ -85,10 +86,8 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
.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<SysDept> deptList = deptMapper.selectListByParentId(user.getDeptId());
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
ids.add(user.getDeptId());
w.in("u.dept_id", ids);
String deptIds = SpringUtils.getBean(ISysDataScopeService.class).getDeptAndChild(user.getDeptId());
w.in("u.dept_id", StringUtils.splitList(deptIds));
}).orderByAsc("u.user_id");
if (StringUtils.isNotBlank(user.getExcludeUserIds())) {
wrapper.notIn("u.user_id", StringUtils.splitTo(user.getExcludeUserIds(), Convert::toLong));