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