fix(llm): 修复删除知识库时未删除对应文档的问题- 更新 KnowledgeBaseServiceImpl 中删除知识库的逻辑
- 修改 KnowledgeDocumentsMapper 中获取已删除文档 ID 的 SQL 查询 - 修正 RagHttpService 中获取知识文档的方法
This commit is contained in:
parent
216378d20d
commit
d5c789bea1
@ -28,7 +28,7 @@ public interface KnowledgeDocumentsMapper extends BaseMapperX<KnowledgeDocuments
|
||||
.orderByDesc(KnowledgeDocumentsDO::getId));
|
||||
}
|
||||
|
||||
@Select("SELECT id FROM llm_knowledge_documents WHERE knowledge_base_id = #{id} and deleted = 1")
|
||||
@Select("SELECT id FROM llm_knowledge_documents WHERE knowledge_base_id = #{id}")
|
||||
List<Long> selectDeleteIds(Long id);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -723,7 +723,7 @@ public class RagHttpService {
|
||||
private KnowledgeDocumentsDO getKnowledgeDocuments (Long id, String fileId) {
|
||||
return knowledgeDocumentsMapper.selectOne(new LambdaQueryWrapperX<KnowledgeDocumentsDO>()
|
||||
.eq(KnowledgeDocumentsDO::getKnowledgeBaseId, id)
|
||||
.eq(KnowledgeDocumentsDO::getId, fileId));
|
||||
.eq(KnowledgeDocumentsDO::getFileId, fileId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -120,6 +120,7 @@ public class KnowledgeBaseServiceImpl implements KnowledgeBaseService {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 获取需要保留的文档 ID
|
||||
List<Long> retainedIds = documents.stream()
|
||||
.map(KnowledgeDocumentsSaveReqVO::getId)
|
||||
@ -186,9 +187,9 @@ public class KnowledgeBaseServiceImpl implements KnowledgeBaseService {
|
||||
KnowledgeDocumentsDO docDO = BeanUtils.toBean(doc, KnowledgeDocumentsDO.class);
|
||||
docDO.setKnowledgeBaseId(knowledgeBaseId);
|
||||
if (doc.getId() == null) {
|
||||
newDocuments.add(docDO); // 收集新增文档
|
||||
newDocuments.add(docDO);
|
||||
}
|
||||
knowledgeDocumentsMapper.insertOrUpdate(docDO); // 更新或插入文档
|
||||
knowledgeDocumentsMapper.insertOrUpdate(docDO);
|
||||
});
|
||||
return newDocuments;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user