在上传文件和关联数据表时,增加对上传目录是否是软连接目录判断,如果是则上传到真实目录

master
guoxin 1 year ago
parent 9c575cb77c
commit bb23b0d78b
  1. 8
      shandan-bianmu/src/main/java/com/keyware/shandan/bianmu/controller/DirectoryController.java
  2. 10
      shandan-system/src/main/java/com/keyware/shandan/bianmu/service/DirectoryTreeService.java
  3. 2
      shandan-system/src/main/java/com/keyware/shandan/system/controller/SysFileController.java
  4. 4
      shandan-system/src/main/java/com/keyware/shandan/system/service/impl/SysFileServiceImpl.java

@ -76,10 +76,14 @@ public class DirectoryController extends BaseController<DirectoryService, Direct
DirectoryVo dir = directoryService.getById(directoryId);
Assert.notNull(dir, "目录不存在");
if (DirectoryType.LINK_DIR == dir.getDirectoryType()) {
dir = directoryService.getById(dir.getResourceId());
Assert.notNull(dir, "软连接源目录不存在");
}
String parentId = dir.getId();
// 将关联的数据资源插入到目录表中去
List<DirectoryVo> metaDirList = Arrays.stream(metadataIds.split(","))
.map(id -> directoryBuilder.buildMetadataDir(directoryId, id))
.map(id -> directoryBuilder.buildMetadataDir(parentId, id))
.collect(Collectors.toList());
directoryService.saveBatch(metaDirList);

@ -153,7 +153,7 @@ public class DirectoryTreeService {
}
Set<String> allowDirIds = dirPermissionService.getByReadPermis(SecurityUtil.getLoginSysUser());
Set<String> dirIds = allDir.stream().map(DirectoryVo::getId).filter(allowDirIds::contains).collect(Collectors.toSet());
dirIds.add(parentId);
//dirIds.add(DirectoryType.LINK_DIR == parent.getDirectoryType() ? parent.getResourceId() : parentId);
QueryWrapper<DirectoryResource> query = new QueryWrapper<>();
query.in("PARENT_ID", dirIds);
if (StringUtils.hasText(text)) {
@ -169,6 +169,14 @@ public class DirectoryTreeService {
private void allDirectoryByParent(DirectoryVo parent, HashSet<DirectoryVo> result) {
String parentId = DirectoryType.LINK_DIR == parent.getDirectoryType() ? parent.getResourceId() : parent.getId();
if(DirectoryType.LINK_DIR == parent.getDirectoryType()){
DirectoryVo linkDir = directoryService.getById(parent.getResourceId());
if(linkDir != null){
result.add(linkDir);
}
}else{
result.add(parent);
}
List<DirectoryVo> children = directoryService.childrenListByParent(parentId);
children.forEach(dir -> {
result.add(dir);

@ -200,7 +200,7 @@ public class SysFileController extends BaseController<SysFileService, SysFile, S
*/
@PostMapping("/upload/chunk/complete")
public Result<Object> mergerChunk(SysFile file) throws Exception {
FileChunkUploadUtil.mergeChunk(file, sysFIle -> sysFileService.save(sysFIle));
FileChunkUploadUtil.mergeChunk(file, sysFile -> sysFileService.save(sysFile));
return Result.of(sysFileService.autoCreateDirAndUpdateFile(file));
}

@ -216,6 +216,10 @@ public class SysFileServiceImpl extends BaseServiceImpl<SysFileMapper, SysFile,
// 当前选中的目录
DirectoryVo currentDir = directoryService.getById(file.getEntityId());
Assert.notNull(currentDir, "资源目录未找到,目录ID:" + file.getEntityId());
if (DirectoryType.LINK_DIR == currentDir.getDirectoryType()) {
currentDir = directoryService.getById(currentDir.getResourceId());
Assert.notNull(currentDir, "软连接的源目录未找到,目录ID:" + file.getEntityId());
}
// 根据文件全路径生成目录
DirectoryVo parentDir = getOrCreateDirectoryByPath(file, currentDir);