优化代码

This commit is contained in:
chenxudong 2025-02-18 10:51:33 +08:00
parent cfa56f3913
commit 3d562bdc5a
2 changed files with 14 additions and 5 deletions

View File

@ -79,10 +79,9 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
@PostConstruct
public void init() {
String osName = System.getProperty("os.name").toLowerCase();
uploadDataDir = osName.startsWith("win") ? environment.getProperty("data.upload.windows.tmp.path") : environment.getProperty("data.upload.linux.tmp.path");
downloadDataDir = osName.startsWith("win") ? environment.getProperty("data.download.windows.tmp.path") : environment.getProperty("data.download.linux.tmp.path");
tmpDir = osName.startsWith("win") ? environment.getProperty("data.windows.tmp.path") : environment.getProperty("data.linux.tmp.path");
uploadDataDir = EleCommonUtil.isWinOs() ? environment.getProperty("data.upload.windows.tmp.path") : environment.getProperty("data.upload.linux.tmp.path");
downloadDataDir = EleCommonUtil.isWinOs() ? environment.getProperty("data.download.windows.tmp.path") : environment.getProperty("data.download.linux.tmp.path");
tmpDir = EleCommonUtil.isWinOs() ? environment.getProperty("data.windows.tmp.path") : environment.getProperty("data.linux.tmp.path");
}
/**

View File

@ -29,6 +29,13 @@ public final class EleCommonUtil {
PARSE_MAP.put("ppt", new PptParse());
PARSE_MAP.put("pptx", new PptParse());
PARSE_MAP.put("text", new TextParse());
PARSE_MAP.put("txt", new TextParse());
PARSE_MAP.put("java", new TextParse());
PARSE_MAP.put("py", new TextParse());
PARSE_MAP.put("cpp", new TextParse());
PARSE_MAP.put("css", new TextParse());
PARSE_MAP.put("html", new TextParse());
PARSE_MAP.put("h", new TextParse());
PARSE_MAP.put("pdf", new PdfParse());
}
@ -93,7 +100,10 @@ public final class EleCommonUtil {
public static String parse(InputStream inputStream, String fileType) {
FileParse fileParse = PARSE_MAP.getOrDefault(fileType, new TextParse());
FileParse fileParse = PARSE_MAP.getOrDefault(fileType, null);
if (fileParse == null) {
return "";
}
return fileParse.parseAllText(inputStream, fileType);
}