fix:1.启用验证码 2.FTP目录创建问题

This commit is contained in:
nieziyan 2023-10-13 11:13:47 +08:00
parent 6c7c4d8724
commit 54d1e95474
4 changed files with 23 additions and 5 deletions

View File

@ -44,4 +44,6 @@ public interface Prompt {
String FILE_IS_EMPTY = "The List Of Files You Uploaded Is Empty!"; String FILE_IS_EMPTY = "The List Of Files You Uploaded Is Empty!";
String NEED_TIME = "The Start Time Or End Time Cannot Be Empty!"; String NEED_TIME = "The Start Time Or End Time Cannot Be Empty!";
String DIR_CREATE_FAIL = "Directory Creation Failure: ";
} }

View File

@ -7,6 +7,7 @@ import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile; import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply; import org.apache.commons.net.ftp.FTPReply;
import org.jeecg.common.constant.SymbolConstant;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -279,4 +280,18 @@ public class FTPUtil {
} }
} }
public static boolean createDirs(FTPClient ftp , String path) throws IOException {
/* 该部分为逐级创建 */
String[] split = path.split(SymbolConstant.SINGLE_SLASH);
for (String str : split) {
if(StringUtils.isBlank(str))
continue;
if (!ftp.changeWorkingDirectory(str)) {
boolean makeDir = ftp.makeDirectory(str);
if (!makeDir) return false;
ftp.changeWorkingDirectory(str);
}
}
return true;
}
} }

View File

@ -80,9 +80,9 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService {
ftpClient = ftpUtil.LoginFTP(); ftpClient = ftpUtil.LoginFTP();
if (ObjectUtil.isNull(ftpClient)) if (ObjectUtil.isNull(ftpClient))
return Result.error(Prompt.FTP_ERR); return Result.error(Prompt.FTP_ERR);
// 如果指定目录不存在,创建目录 // 如果指定目录不存在,逐级创建目录
boolean exist = ftpClient.changeWorkingDirectory(filePath); boolean created = FTPUtil.createDirs(ftpClient, filePath);
if (!exist) ftpClient.makeDirectory(filePath); if (!created) return Result.error(Prompt.DIR_CREATE_FAIL + filePath);
// 上传所有文件 // 上传所有文件
for (File oneFile : fileList) { for (File oneFile : fileList) {
String fullFilePath = filePath + slash + oneFile.getName(); String fullFilePath = filePath + slash + oneFile.getName();

View File

@ -29,6 +29,7 @@ import org.jeecg.modules.system.service.impl.SysBaseApiImpl;
import org.jeecg.modules.system.util.RandImageUtil; import org.jeecg.modules.system.util.RandImageUtil;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -87,7 +88,7 @@ public class LoginController {
//update-begin-author:taoyan date:20190828 for:校验验证码 //update-begin-author:taoyan date:20190828 for:校验验证码
/* String captcha = sysLoginModel.getCaptcha(); String captcha = sysLoginModel.getCaptcha();
if(captcha==null){ if(captcha==null){
result.error500("验证码无效"); result.error500("验证码无效");
return result; return result;
@ -106,7 +107,7 @@ public class LoginController {
// 改成特殊的code 便于前端判断 // 改成特殊的code 便于前端判断
result.setCode(HttpStatus.PRECONDITION_FAILED.value()); result.setCode(HttpStatus.PRECONDITION_FAILED.value());
return result; return result;
}*/ }
//update-end-author:taoyan date:20190828 for:校验验证码 //update-end-author:taoyan date:20190828 for:校验验证码
//1. 校验用户是否有效 //1. 校验用户是否有效