6
This commit is contained in:
@@ -21,17 +21,20 @@ class DocumentRepository:
|
||||
self,
|
||||
kb_id: str,
|
||||
*,
|
||||
category_id: str | None = None,
|
||||
page: int = 1,
|
||||
page_size: int = 50,
|
||||
status: str | None = None,
|
||||
) -> tuple[list[Document], int]:
|
||||
"""分页获取知识库的文档列表。"""
|
||||
"""分页获取知识库的文档列表。支持按分类过滤。"""
|
||||
conditions = [
|
||||
Document.knowledge_base_id == kb_id,
|
||||
Document.status != "DELETED",
|
||||
]
|
||||
if status:
|
||||
conditions.append(Document.status == status)
|
||||
if category_id:
|
||||
conditions.append(Document.category_id == category_id)
|
||||
|
||||
count_stmt = select(func.count()).select_from(Document).where(*conditions)
|
||||
total = self._session.scalar(count_stmt) or 0
|
||||
|
||||
Reference in New Issue
Block a user