- 新增 PlatformRule 模型 (draft/active/inactive 状态流转) - 新增文档解析服务 (PDF/Word/Excel → 纯文本) - 新增 4 个 API: 解析/确认/查询/删除平台规则 - 脚本审核优先从 DB 读取 active 规则,硬编码兜底 - 视频审核合并平台规则违禁词到检测列表 - Alembic 迁移 006: platform_rules 表 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
70 lines
1.9 KiB
Python
70 lines
1.9 KiB
Python
"""
|
||
平台规则相关 Schema
|
||
"""
|
||
from typing import Optional
|
||
from pydantic import BaseModel, Field
|
||
|
||
|
||
class PlatformRuleParseRequest(BaseModel):
|
||
"""上传文档并解析"""
|
||
document_url: str = Field(..., description="TOS 上传后的文件 URL")
|
||
document_name: str = Field(..., description="原始文件名(用于判断格式)")
|
||
platform: str = Field(..., description="目标平台 (douyin/xiaohongshu/bilibili/kuaishou)")
|
||
brand_id: str = Field(..., description="品牌 ID")
|
||
|
||
|
||
class ParsedRulesData(BaseModel):
|
||
"""AI 解析出的结构化规则"""
|
||
forbidden_words: list[str] = Field(default_factory=list, description="违禁词列表")
|
||
restricted_words: list[dict] = Field(
|
||
default_factory=list,
|
||
description="限制词 [{word, condition, suggestion}]",
|
||
)
|
||
duration: Optional[dict] = Field(
|
||
None,
|
||
description="时长要求 {min_seconds, max_seconds}",
|
||
)
|
||
content_requirements: list[str] = Field(
|
||
default_factory=list,
|
||
description="内容要求(如'必须展示产品')",
|
||
)
|
||
other_rules: list[dict] = Field(
|
||
default_factory=list,
|
||
description="其他规则 [{rule, description}]",
|
||
)
|
||
|
||
|
||
class PlatformRuleParseResponse(BaseModel):
|
||
"""解析响应(draft 状态)"""
|
||
id: str
|
||
platform: str
|
||
brand_id: str
|
||
document_url: str
|
||
document_name: str
|
||
parsed_rules: ParsedRulesData
|
||
status: str
|
||
|
||
|
||
class PlatformRuleConfirmRequest(BaseModel):
|
||
"""确认/编辑解析结果"""
|
||
parsed_rules: ParsedRulesData = Field(..., description="品牌方可能修改过的规则")
|
||
|
||
|
||
class PlatformRuleResponse(BaseModel):
|
||
"""完整响应"""
|
||
id: str
|
||
platform: str
|
||
brand_id: str
|
||
document_url: str
|
||
document_name: str
|
||
parsed_rules: ParsedRulesData
|
||
status: str
|
||
created_at: str
|
||
updated_at: str
|
||
|
||
|
||
class PlatformRuleListResponse(BaseModel):
|
||
"""列表响应"""
|
||
items: list[PlatformRuleResponse]
|
||
total: int
|