feat(core): 完成 Phase 2 核心功能开发
- 实现查询API (query.py): 支持star_id/unique_id/nickname三种查询方式 - 实现计算模块 (calculator.py): CPM/自然搜索UV/搜索成本计算 - 实现品牌API集成 (brand_api.py): 批量并发调用,10并发限制 - 实现导出服务 (export_service.py): Excel/CSV导出 - 前端组件: QueryForm/ResultTable/ExportButton - 主页面集成: 支持6种页面状态 - 测试: 44个测试全部通过,覆盖率88% Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
from typing import List, Literal, Optional
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class QueryRequest(BaseModel):
|
||||
"""查询请求模型."""
|
||||
|
||||
type: Literal["star_id", "unique_id", "nickname"] = Field(
|
||||
..., description="查询类型: star_id, unique_id, nickname"
|
||||
)
|
||||
values: List[str] = Field(
|
||||
..., description="查询值列表 (批量ID 或单个昵称)", min_length=1
|
||||
)
|
||||
|
||||
|
||||
class VideoData(BaseModel):
|
||||
"""视频数据模型."""
|
||||
|
||||
# 基础信息
|
||||
item_id: str
|
||||
title: Optional[str] = None
|
||||
viral_type: Optional[str] = None
|
||||
video_url: Optional[str] = None
|
||||
star_id: str
|
||||
star_unique_id: str
|
||||
star_nickname: str
|
||||
publish_time: Optional[datetime] = None
|
||||
|
||||
# 曝光指标
|
||||
natural_play_cnt: int = 0
|
||||
heated_play_cnt: int = 0
|
||||
total_play_cnt: int = 0
|
||||
|
||||
# 互动指标
|
||||
total_interact: int = 0
|
||||
like_cnt: int = 0
|
||||
share_cnt: int = 0
|
||||
comment_cnt: int = 0
|
||||
|
||||
# 效果指标
|
||||
new_a3_rate: Optional[float] = None
|
||||
after_view_search_uv: int = 0
|
||||
return_search_cnt: int = 0
|
||||
|
||||
# 商业信息
|
||||
industry_id: Optional[str] = None
|
||||
industry_name: Optional[str] = None
|
||||
brand_id: Optional[str] = None
|
||||
brand_name: Optional[str] = None # 从品牌 API 获取
|
||||
estimated_video_cost: float = 0
|
||||
|
||||
# 计算字段
|
||||
estimated_natural_cpm: Optional[float] = None
|
||||
estimated_natural_search_uv: Optional[float] = None
|
||||
estimated_natural_search_cost: Optional[float] = None
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class QueryResponse(BaseModel):
|
||||
"""查询响应模型."""
|
||||
|
||||
success: bool = True
|
||||
data: List[VideoData] = []
|
||||
total: int = 0
|
||||
error: Optional[str] = None
|
||||
Reference in New Issue
Block a user