新增:根据文件夹路径查询所有文件夹和文件
This commit is contained in:
@@ -26,7 +26,9 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -47,6 +49,12 @@ public class DataFileController implements IDataFeignClient {
|
||||
@Autowired
|
||||
private IDataFileService IDataFileService;
|
||||
|
||||
/**
|
||||
* 本地可访问的基础路径
|
||||
*/
|
||||
@Value("${local.file.basePath:/home/simulation}")
|
||||
private String LOCAL_BASE_STORAGE_PATH ;
|
||||
|
||||
/**
|
||||
* 创建文件夹
|
||||
*
|
||||
@@ -783,4 +791,14 @@ public class DataFileController implements IDataFeignClient {
|
||||
return IDataFileService.getFileMinioObjectkeysByDirIds(dirIds);
|
||||
}
|
||||
|
||||
@PostMapping("/getLocalFiles")
|
||||
public SdmResponse<List<LocalFileNodeVO>> scanDir(@RequestBody LocalFileListReq req) {
|
||||
String folderPath = req.getFolderPath();
|
||||
if(StringUtils.isBlank(folderPath)||!folderPath.startsWith(LOCAL_BASE_STORAGE_PATH)) {
|
||||
throw new RuntimeException("目录路径非法");
|
||||
}
|
||||
List<LocalFileNodeVO> localFiles = FilesUtil.listFiles(folderPath);
|
||||
return SdmResponse.success(localFiles);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.sdm.data.model.req;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LocalFileListReq {
|
||||
/**
|
||||
* 目录路径
|
||||
*/
|
||||
@NotBlank
|
||||
private String folderPath;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user