mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 17:38:48 +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.SysDeptMapper;
|
||||||
import org.dromara.system.mapper.SysRoleMapper;
|
import org.dromara.system.mapper.SysRoleMapper;
|
||||||
import org.dromara.system.mapper.SysUserMapper;
|
import org.dromara.system.mapper.SysUserMapper;
|
||||||
|
import org.dromara.system.service.ISysDataScopeService;
|
||||||
import org.dromara.system.service.ISysDeptService;
|
import org.dromara.system.service.ISysDeptService;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
@ -110,11 +111,8 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
|||||||
if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
|
if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
|
||||||
//部门树搜索
|
//部门树搜索
|
||||||
lqw.and(x -> {
|
lqw.and(x -> {
|
||||||
Long parentId = bo.getBelongDeptId();
|
String deptIds = SpringUtils.getBean(ISysDataScopeService.class).getDeptAndChild(bo.getBelongDeptId());
|
||||||
List<SysDept> deptList = baseMapper.selectListByParentId(parentId);
|
x.in(SysDept::getDeptId, StringUtils.splitList(deptIds));
|
||||||
List<Long> deptIds = StreamUtils.toList(deptList, SysDept::getDeptId);
|
|
||||||
deptIds.add(parentId);
|
|
||||||
x.in(SysDept::getDeptId, deptIds);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return lqw;
|
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.exception.ServiceException;
|
||||||
import org.dromara.common.core.service.PostService;
|
import org.dromara.common.core.service.PostService;
|
||||||
import org.dromara.common.core.utils.MapstructUtils;
|
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.StreamUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
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.SysPost;
|
||||||
import org.dromara.system.domain.SysUserPost;
|
import org.dromara.system.domain.SysUserPost;
|
||||||
import org.dromara.system.domain.bo.SysPostBo;
|
import org.dromara.system.domain.bo.SysPostBo;
|
||||||
import org.dromara.system.domain.vo.SysPostVo;
|
import org.dromara.system.domain.vo.SysPostVo;
|
||||||
import org.dromara.system.mapper.SysDeptMapper;
|
|
||||||
import org.dromara.system.mapper.SysPostMapper;
|
import org.dromara.system.mapper.SysPostMapper;
|
||||||
import org.dromara.system.mapper.SysUserPostMapper;
|
import org.dromara.system.mapper.SysUserPostMapper;
|
||||||
|
import org.dromara.system.service.ISysDataScopeService;
|
||||||
import org.dromara.system.service.ISysPostService;
|
import org.dromara.system.service.ISysPostService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -39,7 +39,6 @@ import java.util.Map;
|
|||||||
public class SysPostServiceImpl implements ISysPostService, PostService {
|
public class SysPostServiceImpl implements ISysPostService, PostService {
|
||||||
|
|
||||||
private final SysPostMapper baseMapper;
|
private final SysPostMapper baseMapper;
|
||||||
private final SysDeptMapper deptMapper;
|
|
||||||
private final SysUserPostMapper userPostMapper;
|
private final SysUserPostMapper userPostMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -92,10 +91,8 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
|||||||
} else if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
|
} else if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
|
||||||
//部门树搜索
|
//部门树搜索
|
||||||
wrapper.and(x -> {
|
wrapper.and(x -> {
|
||||||
List<SysDept> deptList = deptMapper.selectListByParentId(bo.getBelongDeptId());
|
String deptIds = SpringUtils.getBean(ISysDataScopeService.class).getDeptAndChild(bo.getBelongDeptId());
|
||||||
List<Long> deptIds = StreamUtils.toList(deptList, SysDept::getDeptId);
|
x.in(SysPost::getDeptId, StringUtils.splitList(deptIds));
|
||||||
deptIds.add(bo.getBelongDeptId());
|
|
||||||
x.in(SysPost::getDeptId, deptIds);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return wrapper;
|
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.SysUserExportVo;
|
||||||
import org.dromara.system.domain.vo.SysUserVo;
|
import org.dromara.system.domain.vo.SysUserVo;
|
||||||
import org.dromara.system.mapper.*;
|
import org.dromara.system.mapper.*;
|
||||||
|
import org.dromara.system.service.ISysDataScopeService;
|
||||||
import org.dromara.system.service.ISysUserService;
|
import org.dromara.system.service.ISysUserService;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
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,
|
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||||
"u.create_time", params.get("beginTime"), params.get("endTime"))
|
"u.create_time", params.get("beginTime"), params.get("endTime"))
|
||||||
.and(ObjectUtil.isNotNull(user.getDeptId()), w -> {
|
.and(ObjectUtil.isNotNull(user.getDeptId()), w -> {
|
||||||
List<SysDept> deptList = deptMapper.selectListByParentId(user.getDeptId());
|
String deptIds = SpringUtils.getBean(ISysDataScopeService.class).getDeptAndChild(user.getDeptId());
|
||||||
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
|
w.in("u.dept_id", StringUtils.splitList(deptIds));
|
||||||
ids.add(user.getDeptId());
|
|
||||||
w.in("u.dept_id", ids);
|
|
||||||
}).orderByAsc("u.user_id");
|
}).orderByAsc("u.user_id");
|
||||||
if (StringUtils.isNotBlank(user.getExcludeUserIds())) {
|
if (StringUtils.isNotBlank(user.getExcludeUserIds())) {
|
||||||
wrapper.notIn("u.user_id", StringUtils.splitTo(user.getExcludeUserIds(), Convert::toLong));
|
wrapper.notIn("u.user_id", StringUtils.splitTo(user.getExcludeUserIds(), Convert::toLong));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user