mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 09:35:29 +08:00
update 优化部门树搜索
This commit is contained in:
parent
8f5d60f543
commit
05982f1013
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user