feat: 增加技能管理模块试验性功能,等待优化

This commit is contained in:
2026-06-08 16:52:41 +08:00
parent cb379e071c
commit 950148b3f7
68 changed files with 4901 additions and 135 deletions

View File

@@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import tech.easyflow.common.filestorage.FileStorageService;
import tech.easyflow.common.filestorage.utils.PathGeneratorUtil;
@@ -14,8 +15,6 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@Component("local")
@@ -116,6 +115,20 @@ public class LocalFileStorageServiceImpl implements FileStorageService {
@Override
public String save(MultipartFile file, String prePath) {
return save(file);
try {
String path = PathGeneratorUtil.generateUserPath(file.getOriginalFilename());
if (StringUtils.hasText(prePath)) {
String normalized = prePath.replaceAll("^/+", "").replaceAll("/+$", "");
path = normalized + "/" + path.replaceAll("^/+", "");
}
File target = getLocalFile(path);
if (!target.getParentFile().exists() && !target.getParentFile().mkdirs()) {
LOG.error("创建文件失败: {} ", target.getParentFile());
}
file.transferTo(target);
return prefix + path;
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
}