|
|
@ -143,32 +143,37 @@ public class DirectoryTreeService { |
|
|
|
return directoryService.list(wrapper); |
|
|
|
return directoryService.list(wrapper); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Page<DirectoryResource> directoryResourcePage(Page<DirectoryResource> page, DirectoryResource directoryResource) { |
|
|
|
public Page<DirectoryResource> resourcePage(Page<DirectoryResource> page, String parentId, String text, boolean all) { |
|
|
|
QueryWrapper<DirectoryResource> wrapper = new QueryWrapper<>(directoryResource); |
|
|
|
DirectoryVo parent = directoryService.getById(parentId); |
|
|
|
|
|
|
|
HashSet<DirectoryVo> allDir = new HashSet<>(); |
|
|
|
|
|
|
|
if (all) { |
|
|
|
|
|
|
|
allDirectoryByParent(parent, allDir); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
allDir.addAll(directoryService.childrenListByParent(parentId)); |
|
|
|
|
|
|
|
} |
|
|
|
Set<String> allowDirIds = dirPermissionService.getByReadPermis(SecurityUtil.getLoginSysUser()); |
|
|
|
Set<String> allowDirIds = dirPermissionService.getByReadPermis(SecurityUtil.getLoginSysUser()); |
|
|
|
//
|
|
|
|
Set<String> dirIds = allDir.stream().map(DirectoryVo::getId).filter(allowDirIds::contains).collect(Collectors.toSet()); |
|
|
|
if (StringUtils.hasText(directoryResource.getResourceName())) { |
|
|
|
dirIds.add(parentId); |
|
|
|
wrapper.and(queryWrapper -> { |
|
|
|
QueryWrapper<DirectoryResource> query = new QueryWrapper<>(); |
|
|
|
|
|
|
|
query.in("PARENT_ID", dirIds); |
|
|
|
|
|
|
|
if (StringUtils.hasText(text)) { |
|
|
|
|
|
|
|
query.and(queryWrapper -> { |
|
|
|
queryWrapper. |
|
|
|
queryWrapper. |
|
|
|
like("RESOURCE_NAME", directoryResource.getResourceName()) |
|
|
|
like("RESOURCE_NAME", text) |
|
|
|
.or() |
|
|
|
.or() |
|
|
|
.like("RESOURCE_COMMENT", directoryResource.getResourceName()); |
|
|
|
.like("RESOURCE_COMMENT", text); |
|
|
|
}); |
|
|
|
}); |
|
|
|
directoryResource.setResourceName(null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (directoryResource.getDirectoryPath() != null) { |
|
|
|
|
|
|
|
String path = directoryResource.getDirectoryPath(); |
|
|
|
|
|
|
|
if (path.endsWith("/")) { |
|
|
|
|
|
|
|
path = path.substring(0, path.length() - 1); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
DirectoryVo parent = directoryService.getByPath(path); |
|
|
|
return directoryResourceMapper.selectPage(page, query); |
|
|
|
List<DirectoryVo> dirList = directoryService.childrenLists(parent); |
|
|
|
|
|
|
|
HashSet<String> ids = (HashSet<String>) dirList.stream().filter(child -> allowDirIds.contains(child.getId())).map(DirectoryVo::getId).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
ids.add(parent.getId()); |
|
|
|
|
|
|
|
wrapper.in("PARENT_ID", ids); |
|
|
|
|
|
|
|
directoryResource.setDirectoryPath(null); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return directoryResourceMapper.selectPage(page, wrapper); |
|
|
|
|
|
|
|
|
|
|
|
private void allDirectoryByParent(DirectoryVo parent, HashSet<DirectoryVo> result) { |
|
|
|
|
|
|
|
String parentId = DirectoryType.LINK_DIR == parent.getDirectoryType() ? parent.getResourceId() : parent.getId(); |
|
|
|
|
|
|
|
List<DirectoryVo> children = directoryService.childrenListByParent(parentId); |
|
|
|
|
|
|
|
children.forEach(dir -> { |
|
|
|
|
|
|
|
result.add(dir); |
|
|
|
|
|
|
|
allDirectoryByParent(dir, result); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static class DirectoryParentBuilder { |
|
|
|
private static class DirectoryParentBuilder { |
|
|
|