|
|
|
@ -143,32 +143,37 @@ public class DirectoryTreeService { |
|
|
|
|
return directoryService.list(wrapper); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Page<DirectoryResource> directoryResourcePage(Page<DirectoryResource> page, DirectoryResource directoryResource) { |
|
|
|
|
QueryWrapper<DirectoryResource> wrapper = new QueryWrapper<>(directoryResource); |
|
|
|
|
public Page<DirectoryResource> resourcePage(Page<DirectoryResource> page, String parentId, String text, boolean all) { |
|
|
|
|
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()); |
|
|
|
|
//
|
|
|
|
|
if (StringUtils.hasText(directoryResource.getResourceName())) { |
|
|
|
|
wrapper.and(queryWrapper -> { |
|
|
|
|
Set<String> dirIds = allDir.stream().map(DirectoryVo::getId).filter(allowDirIds::contains).collect(Collectors.toSet()); |
|
|
|
|
dirIds.add(parentId); |
|
|
|
|
QueryWrapper<DirectoryResource> query = new QueryWrapper<>(); |
|
|
|
|
query.in("PARENT_ID", dirIds); |
|
|
|
|
if (StringUtils.hasText(text)) { |
|
|
|
|
query.and(queryWrapper -> { |
|
|
|
|
queryWrapper. |
|
|
|
|
like("RESOURCE_NAME", directoryResource.getResourceName()) |
|
|
|
|
like("RESOURCE_NAME", text) |
|
|
|
|
.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); |
|
|
|
|
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, query); |
|
|
|
|
} |
|
|
|
|
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 { |
|
|
|
|