WIP-CHECKPOINT[auth-refactor]: 固化工程师崩溃前部分成果 + 同树其他未提交WIP(仅源码,不含密钥/二进制)-- 待重激活工程师续作
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
# =============================================================================
|
||||
# 企微IT智能服务台 — 知识库 Pydantic Schema
|
||||
# =============================================================================
|
||||
# 说明:定义知识库FAQ的请求/响应数据结构
|
||||
# 支持 CRUD 操作:创建、读取、更新、删除
|
||||
# =============================================================================
|
||||
|
||||
from datetime import datetime
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# 创建知识库条目 Schema
|
||||
# --------------------------------------------------------------------------
|
||||
class KnowledgeBaseCreate(BaseModel):
|
||||
"""创建知识库条目请求 Schema。"""
|
||||
|
||||
category: str = Field(default="其他", max_length=64, description="分类")
|
||||
title: str = Field(..., min_length=1, max_length=256, description="问题标题")
|
||||
content: str = Field(..., min_length=1, description="答案内容")
|
||||
tags: List[str] = Field(default_factory=list, description="标签列表")
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# 更新知识库条目 Schema
|
||||
# --------------------------------------------------------------------------
|
||||
class KnowledgeBaseUpdate(BaseModel):
|
||||
"""更新知识库条目请求 Schema。"""
|
||||
|
||||
category: Optional[str] = Field(None, max_length=64, description="分类")
|
||||
title: Optional[str] = Field(None, max_length=256, description="问题标题")
|
||||
content: Optional[str] = Field(None, description="答案内容")
|
||||
tags: Optional[List[str]] = Field(None, description="标签列表")
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# 知识库条目响应 Schema
|
||||
# --------------------------------------------------------------------------
|
||||
class KnowledgeBaseResponse(BaseModel):
|
||||
"""知识库条目响应 Schema。"""
|
||||
|
||||
id: str
|
||||
category: str
|
||||
title: str
|
||||
content: str
|
||||
tags: List[str]
|
||||
view_count: int = 0
|
||||
use_count: int = 0
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# 知识库列表响应 Schema
|
||||
# --------------------------------------------------------------------------
|
||||
class KnowledgeBaseListResponse(BaseModel):
|
||||
"""知识库列表响应 Schema。"""
|
||||
|
||||
items: List[KnowledgeBaseResponse]
|
||||
Reference in New Issue
Block a user