132 lines
3.0 KiB
Python
132 lines
3.0 KiB
Python
"""内容分发相关 Pydantic schemas"""
|
|
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
# ---------- 平台信息 ----------
|
|
|
|
class FormatFeatures(BaseModel):
|
|
"""平台格式特性"""
|
|
supports_markdown: bool = False
|
|
supports_html: bool = False
|
|
max_heading_level: int = 0
|
|
supports_code_block: bool = False
|
|
supports_emoji: bool = False
|
|
|
|
|
|
class PlatformInfo(BaseModel):
|
|
"""平台信息响应"""
|
|
id: str
|
|
name: str
|
|
icon: str
|
|
max_title_length: int
|
|
max_content_length: int
|
|
min_content_length: int
|
|
supported_media: list[str]
|
|
max_images: int
|
|
best_publish_times: list[str] = []
|
|
best_publish_days: list[str] = []
|
|
format_features: FormatFeatures | None = None
|
|
rules: list[str] = []
|
|
seo_tips: list[str] = []
|
|
|
|
|
|
class PlatformListResponse(BaseModel):
|
|
"""平台列表响应"""
|
|
platforms: list[PlatformInfo]
|
|
|
|
|
|
# ---------- 内容校验 ----------
|
|
|
|
class ContentValidateRequest(BaseModel):
|
|
"""内容校验请求"""
|
|
content: str = Field(min_length=1)
|
|
title: str = Field(min_length=1)
|
|
platform: str
|
|
|
|
|
|
class ValidationIssue(BaseModel):
|
|
"""校验问题"""
|
|
severity: str = Field(pattern=r"^(high|medium|low)$")
|
|
message: str
|
|
|
|
|
|
class ContentValidateResponse(BaseModel):
|
|
"""内容校验响应"""
|
|
is_valid: bool
|
|
score: int = Field(ge=0, le=100)
|
|
issues: list[ValidationIssue]
|
|
passed: list[str]
|
|
|
|
|
|
# ---------- 发布策略 ----------
|
|
|
|
class PublishStrategyRequest(BaseModel):
|
|
"""发布策略请求"""
|
|
content_title: str = Field(min_length=1)
|
|
platforms: list[str] = Field(min_length=1)
|
|
industry: str = "通用"
|
|
|
|
|
|
class ScheduleItem(BaseModel):
|
|
"""排期项"""
|
|
platform: str
|
|
platform_name: str
|
|
suggested_time: str
|
|
reason: str
|
|
|
|
|
|
class PublishStrategyResponse(BaseModel):
|
|
"""发布策略响应"""
|
|
schedule: list[ScheduleItem]
|
|
tags: dict[str, list[str]]
|
|
tips: list[str]
|
|
|
|
|
|
# ---------- 内容格式化 ----------
|
|
|
|
class ContentFormatRequest(BaseModel):
|
|
"""内容格式化请求"""
|
|
content: str = Field(min_length=1)
|
|
platform: str
|
|
|
|
|
|
class ContentFormatResponse(BaseModel):
|
|
"""内容格式化响应"""
|
|
platform: str
|
|
formatted_content: str
|
|
original_length: int
|
|
formatted_length: int
|
|
|
|
|
|
# ---------- 发布排期 ----------
|
|
|
|
class ScheduleCreateRequest(BaseModel):
|
|
"""创建发布排期请求"""
|
|
content_title: str = Field(min_length=1)
|
|
content_id: str | None = None
|
|
platforms: list[str] = Field(min_length=1)
|
|
industry: str = "通用"
|
|
scheduled_times: dict[str, str] | None = None
|
|
"""自定义各平台发布时间 {platform: "YYYY-MM-DD HH:MM"}"""
|
|
|
|
|
|
class PlatformSchedule(BaseModel):
|
|
"""单个平台排期"""
|
|
platform: str
|
|
platform_name: str
|
|
scheduled_time: str
|
|
status: str = "pending"
|
|
"""pending / published / failed"""
|
|
|
|
|
|
class ScheduleCreateResponse(BaseModel):
|
|
"""创建发布排期响应"""
|
|
schedule_id: str
|
|
content_title: str
|
|
platforms: list[PlatformSchedule]
|
|
tips: list[str]
|
|
created_at: str
|