修复:将目录的子级目录权限赋予普通用户后,普通用户无法查看的问题

master
Guo XIn 1 year ago
parent 5192c15e9c
commit d68ce21926
  1. 17
      shandan-system/src/main/java/com/keyware/shandan/bianmu/service/DirectoryTreeService.java

@ -63,15 +63,18 @@ public class DirectoryTreeService {
Set<String> permisDis = "write".equals(permis) ? dirPermissionService.getByWritePermis(user) : dirPermissionService.getByReadPermis(user); Set<String> permisDis = "write".equals(permis) ? dirPermissionService.getByWritePermis(user) : dirPermissionService.getByReadPermis(user);
// 判断权限范围 // 判断权限范围
List<DirectoryVo> permisDirectoryList = StreamUtil.as(directoryList).filter(dir -> { List<DirectoryVo> permisDirectoryList = StreamUtil.as(directoryList).filter(dir -> {
if(dir.getReviewStatus() == status || status == null){ if (dir.getReviewStatus() == status || status == null) {
boolean permisAllow = permisDis.contains(dir.getId()); boolean permisAllow = permisDis.contains(dir.getId());
if(permisAllow){ if (permisAllow) {
return true; return true;
} }
// 如果权限不允许,则需要判断当前节点的所有子级节点是否有允许的目录,如果有则需要返回到前端的树组件中 // 如果权限不允许,则需要判断当前节点的所有子级节点是否有允许的目录,如果有则需要返回到前端的树组件中
Set<String> childrenIds = getDirectoryList(dir, true, false, busType).stream().map(DirectoryVo::getId).collect(Collectors.toSet()); Set<String> childrenIds = getDirectoryList(dir, true, false, busType)
for(String id : childrenIds){ .stream()
if(permisDis.contains(id)){ .map(DirectoryVo::getId)
.collect(Collectors.toSet());
for (String id : childrenIds) {
if (permisDis.contains(id)) {
return true; return true;
} }
} }
@ -103,9 +106,9 @@ public class DirectoryTreeService {
*/ */
private List<DirectoryVo> getDirectoryList(DirectoryVo parentDir, boolean allChild, boolean hasResource, int busType) { private List<DirectoryVo> getDirectoryList(DirectoryVo parentDir, boolean allChild, boolean hasResource, int busType) {
QueryWrapper<DirectoryVo> wrapper = new QueryWrapper<>(); QueryWrapper<DirectoryVo> wrapper = new QueryWrapper<>();
if(parentDir == null){ if (parentDir == null) {
wrapper.eq("ID", "ROOT"); wrapper.eq("ID", "ROOT");
}else { } else {
wrapper.in(!hasResource, "DIRECTORY_TYPE", DirectoryType.DIRECTORY, DirectoryType.LINK_DIR).eq("IS_BASIC_DIR", busType); wrapper.in(!hasResource, "DIRECTORY_TYPE", DirectoryType.DIRECTORY, DirectoryType.LINK_DIR).eq("IS_BASIC_DIR", busType);
if (parentDir != null) { if (parentDir != null) {
if (allChild) { if (allChild) {