优化代码
This commit is contained in:
parent
be0fb17009
commit
f355631eff
|
|
@ -127,7 +127,7 @@ public class ChatService {
|
||||||
FileUtil.writeFromStream(file.getInputStream(), pdfPath);
|
FileUtil.writeFromStream(file.getInputStream(), pdfPath);
|
||||||
} else {
|
} else {
|
||||||
FileUtil.writeFromStream(file.getInputStream(), srcPath);
|
FileUtil.writeFromStream(file.getInputStream(), srcPath);
|
||||||
if (StrUtil.equals(fileType, "doc") || StrUtil.equals(fileType, "docx")) {
|
if (Arrays.asList("doc", "docx").contains(fileType)) {
|
||||||
OfficeFileUtil.doc2pdf(srcPath, pdfPath);
|
OfficeFileUtil.doc2pdf(srcPath, pdfPath);
|
||||||
} else {
|
} else {
|
||||||
OfficeFileUtil.ppt2pdf(srcPath, pdfPath);
|
OfficeFileUtil.ppt2pdf(srcPath, pdfPath);
|
||||||
|
|
@ -148,9 +148,7 @@ public class ChatService {
|
||||||
List<Document> newDocuments = new ArrayList<>();
|
List<Document> newDocuments = new ArrayList<>();
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
for (Document document : documents) {
|
for (Document document : documents) {
|
||||||
Map<String, Object> metadata = new HashMap<>();
|
Map<String, Object> metadata = Map.of("fileName", file.getOriginalFilename(), "fileMd5", fileMd5);
|
||||||
metadata.put("fileName", file.getOriginalFilename());
|
|
||||||
metadata.put("fileMd5", fileMd5);
|
|
||||||
newDocuments.add(new Document(IdWorker.getSnowFlakeIdString(), Objects.requireNonNull(document.getText()), metadata));
|
newDocuments.add(new Document(IdWorker.getSnowFlakeIdString(), Objects.requireNonNull(document.getText()), metadata));
|
||||||
stringBuilder.append(document.getText());
|
stringBuilder.append(document.getText());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue