49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class TrendInsightRequest(BaseModel):
|
|
brand_id: uuid.UUID = Field(..., description="品牌ID")
|
|
period_days: int = Field(30, ge=7, le=365, description="分析周期天数")
|
|
platforms: list[str] | None = Field(None, description="筛选平台列表")
|
|
keywords: list[str] | None = Field(None, description="筛选关键词列表")
|
|
|
|
|
|
class TrendInsightResponse(BaseModel):
|
|
id: uuid.UUID
|
|
brand_id: uuid.UUID
|
|
trend_type: str
|
|
keyword: str | None
|
|
platform: str | None
|
|
period_start: datetime
|
|
period_end: datetime
|
|
data_points: list | None
|
|
change_rate: float | None
|
|
absolute_change: int | None
|
|
sentiment_trend: dict | None
|
|
cause_analysis: str | None
|
|
recommendations: list | None
|
|
confidence: float
|
|
severity: str
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class TrendInsightList(BaseModel):
|
|
items: list[TrendInsightResponse]
|
|
total: int
|
|
|
|
|
|
class TrendSummary(BaseModel):
|
|
brand_id: uuid.UUID
|
|
period_days: int
|
|
rising_count: int = 0
|
|
declining_count: int = 0
|
|
hotspot_count: int = 0
|
|
top_keywords: list[str] = Field(default_factory=list)
|
|
platform_highlights: dict = Field(default_factory=dict)
|