feat:查询文件夹属性结构接口修改,查询文件接口修改,下载文件接口修改

This commit is contained in:
qiaoqinzheng 2023-05-23 10:15:31 +08:00
parent a17bbc343a
commit bcb2b6b7ed
2 changed files with 13 additions and 6 deletions

View File

@ -67,7 +67,12 @@ public class FTPUtil {
*/
public List<LogManage> findDirectory(FTPClient ftp,List<LogManage> list,Integer parentNum,String filePath){
try {
ftp.changeWorkingDirectory(filePath);
if (filePath.indexOf("/")>0){
List<String> paths = Arrays.asList(filePath.split("/"));
for (String path:paths) {
ftp.changeWorkingDirectory(path);
}
}
List<FTPFile> ftpFiles = Arrays.asList(ftp.listDirectories());
if (CollectionUtils.isNotEmpty(ftpFiles)){
int num =1;
@ -77,12 +82,13 @@ public class FTPUtil {
logManage.setName(file.getName());
logManage.setOrderNum(num);
logManage.setParentNum(parentNum);
logManage.setPath(filePath+ file.getName());
logManage.setPath(filePath +"/"+ file.getName());
list.add(logManage);
num++;
// 需要加此判断否则ftp默认将项目文件所在目录之下的目录./项目文件所在目录向上一级目录下的目录../都纳入递归这样下去就陷入一个死循环了需将其过滤掉
if (!".".equals(file.getName()) && !"..".equals(file.getName())) {
findDirectory(ftp,list,num,file.getName());
findDirectory(ftp,list,num,filePath +"/"+ file.getName());
ftp.changeToParentDirectory();
}
}
}

View File

@ -48,7 +48,7 @@ public class LogManageController {
logManage.setName(ftpFile.getName());
logManage.setOrderNum(num);
logManage.setParentNum(0);
logManage.setPath(workPath+ "/" + ftpFile.getName());
logManage.setPath(workPath + "/" + ftpFile.getName());
result.add(logManage);
num++;
}
@ -56,7 +56,8 @@ public class LogManageController {
if (CollectionUtils.isNotEmpty(result)){
List<LogManage> list = new LinkedList<>();
for (LogManage logManage:result) {
list = ftpUtil.findDirectory(ftpClient, list, logManage.getOrderNum(), logManage.getName());
list = ftpUtil.findDirectory(ftpClient, list, logManage.getOrderNum(), workPath + "/" + logManage.getName());
ftpClient.changeToParentDirectory();
}
result.addAll(list);
}
@ -127,7 +128,7 @@ public class LogManageController {
if (ftpFile.isFile()){
FileInfo fileInfo = new FileInfo();
fileInfo.setFileName(ftpFile.getName());
fileInfo.setFilePath(path+ftpFile.getName());
fileInfo.setFilePath(path +"/"+ ftpFile.getName());
fileInfo.setFileSize(String.format("%.2f", Double.valueOf(Double.valueOf(ftpFile.getSize())/1024)) + "KB");
fileInfo.setFileDate(DateUtils.formatDate(ftpFile.getTimestamp(),"yyyy-MM-dd"));
result.add(fileInfo);