refactor: 临时文件目录使用ruoyi.profile配置
- 移除硬编码的临时目录常量
- 使用ruoyi.profile配置(D:/ruoyi/uploadPath)
- 临时文件存储路径:{ruoyi.profile}/temp/upload
- 复用若依框架统一的文件路径配置
This commit is contained in:
@@ -12,6 +12,7 @@ import com.ruoyi.ccdi.project.service.ICcdiFileUploadService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -46,10 +47,10 @@ import java.util.UUID;
|
||||
public class CcdiFileUploadServiceImpl implements ICcdiFileUploadService {
|
||||
|
||||
/**
|
||||
* 临时文件存储目录
|
||||
* TODO: 应该从配置文件中读取
|
||||
* 临时文件存储目录(基于ruoyi.profile配置)
|
||||
*/
|
||||
private static final String TEMP_FILE_DIR = System.getProperty("java.io.tmpdir") + File.separator + "ccdi-upload";
|
||||
@Value("${ruoyi.profile}/temp/upload")
|
||||
private String tempFileDir;
|
||||
|
||||
@Resource
|
||||
private CcdiFileUploadRecordMapper recordMapper;
|
||||
@@ -153,7 +154,7 @@ public class CcdiFileUploadServiceImpl implements ICcdiFileUploadService {
|
||||
List<String> tempFilePaths = new ArrayList<>();
|
||||
try {
|
||||
// 确保临时目录存在
|
||||
Path tempDir = Paths.get(TEMP_FILE_DIR);
|
||||
Path tempDir = Paths.get(tempFileDir);
|
||||
if (!Files.exists(tempDir)) {
|
||||
Files.createDirectories(tempDir);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user