优化“知识库模块“--基本完善

This commit is contained in:
Cheng Zhou
2025-12-26 14:07:28 +08:00
parent a1a4964cd2
commit 7c9befc3c9
23 changed files with 1345 additions and 110 deletions
+14
View File
@@ -45,6 +45,20 @@ async def get_category(db: AsyncSession, category_id: uuid.UUID) -> FaqCategory
return result.scalar_one_or_none()
async def get_category_by_name(
db: AsyncSession,
study_id: uuid.UUID | None,
name: str,
) -> FaqCategory | None:
stmt = select(FaqCategory).where(FaqCategory.name == name)
if study_id is None:
stmt = stmt.where(FaqCategory.study_id.is_(None))
else:
stmt = stmt.where(FaqCategory.study_id == study_id)
result = await db.execute(stmt)
return result.scalar_one_or_none()
async def update_category(db: AsyncSession, category: FaqCategory, category_in: CategoryUpdate) -> FaqCategory:
update_data = category_in.model_dump(exclude_unset=True)
if update_data: