mirror of
https://github.com/stardrophere/InsightRadar.git
synced 2026-06-06 00:57:51 +08:00
big update
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
# 推送设置相关的请求/响应模型
|
||||
from datetime import datetime
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
# ==========================================
|
||||
# 推送时间表 (UserDeliverySchedule)
|
||||
# ==========================================
|
||||
class DeliveryScheduleCreate(BaseModel):
|
||||
"""新增推送时间请求体,时间格式 HH:MM"""
|
||||
delivery_time: str = Field(..., pattern=r"^\d{2}:\d{2}$", description="每天推送的时间,格式 HH:MM")
|
||||
is_active: bool = Field(default=True, description="是否启用此时段")
|
||||
|
||||
|
||||
class DeliveryScheduleUpdate(BaseModel):
|
||||
"""更新推送时间请求体"""
|
||||
delivery_time: Optional[str] = Field(None, pattern=r"^\d{2}:\d{2}$")
|
||||
is_active: Optional[bool] = None
|
||||
|
||||
|
||||
class DeliveryScheduleResponse(BaseModel):
|
||||
"""推送时间响应体"""
|
||||
id: int
|
||||
user_id: int
|
||||
delivery_time: str
|
||||
is_active: bool
|
||||
created_at: datetime
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
# ==========================================
|
||||
# 推送渠道端点 (UserPushEndpoint)
|
||||
# ==========================================
|
||||
class PushEndpointCreate(BaseModel):
|
||||
"""新增推送渠道请求体"""
|
||||
channel_type: str = Field(..., max_length=50, description="渠道类型,如 EMAIL / WECHAT_BOT / TELEGRAM")
|
||||
channel_account: str = Field(..., max_length=255, description="具体接收账号(邮箱地址/Webhook等)")
|
||||
is_active: bool = Field(default=True, description="是否启用")
|
||||
priority_level: int = Field(default=1, ge=1, le=10, description="优先级,1最高")
|
||||
|
||||
|
||||
class PushEndpointUpdate(BaseModel):
|
||||
"""更新推送渠道请求体"""
|
||||
channel_account: Optional[str] = Field(None, max_length=255)
|
||||
is_active: Optional[bool] = None
|
||||
priority_level: Optional[int] = Field(None, ge=1, le=10)
|
||||
|
||||
|
||||
class PushEndpointResponse(BaseModel):
|
||||
"""推送渠道响应体"""
|
||||
id: int
|
||||
user_id: int
|
||||
channel_type: str
|
||||
channel_account: str
|
||||
is_active: bool
|
||||
priority_level: int
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
# ==========================================
|
||||
# 推送设置聚合响应(一次性返回全部推送配置)
|
||||
# ==========================================
|
||||
class UserDeliveryConfigResponse(BaseModel):
|
||||
"""用户的完整推送配置(时间表 + 渠道列表)"""
|
||||
schedules: List[DeliveryScheduleResponse] = Field(default_factory=list)
|
||||
endpoints: List[PushEndpointResponse] = Field(default_factory=list)
|
||||
@@ -1,23 +1,30 @@
|
||||
# app/schemas/event_schema.py
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import List, Optional
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class PlatformTrendResponse(BaseModel):
|
||||
source_id: int
|
||||
platform_name: str # 平台名称,如 "微博热搜"
|
||||
headline: str # 平台对应的具体热搜标题
|
||||
url: Optional[str] # 跳转链接
|
||||
current_ranking: Optional[int] # 当前排名
|
||||
ranking_history: List[int] # 排名历史轨迹,如 [50, 45, 20, 5, 1],供 ApexCharts 渲染
|
||||
platform_name: str
|
||||
headline: str
|
||||
url: Optional[str]
|
||||
current_ranking: Optional[int]
|
||||
ranking_history: List[int]
|
||||
|
||||
|
||||
class UnifiedEventResponse(BaseModel):
|
||||
event_id: int
|
||||
unified_title: str # AI 生成的统一大标题
|
||||
summary: Optional[str] # AI 生成的摘要
|
||||
hot_score: int # 总热度值
|
||||
created_at: datetime # 事件发现时间
|
||||
platforms: List[PlatformTrendResponse] # 挂载的各个平台子热搜
|
||||
# tags: List[str] = [] # 如果后续打通了 ExtractedTopic,可以在这里返回标签
|
||||
unified_title: str
|
||||
summary: Optional[str]
|
||||
hot_score: int
|
||||
created_at: datetime
|
||||
platforms: List[PlatformTrendResponse]
|
||||
tags: List[str] = Field(default_factory=list)
|
||||
|
||||
|
||||
class PaginatedUnifiedEventResponse(BaseModel):
|
||||
"""分页包装:避免一次性返回全量数据"""
|
||||
total: int
|
||||
has_more: bool
|
||||
data: List[UnifiedEventResponse]
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
from datetime import datetime
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class UserTopicPreferenceCreate(BaseModel):
|
||||
"""新增用户兴趣词请求体。"""
|
||||
interested_keyword: str = Field(..., min_length=1, max_length=100, description="用户感兴趣的关键词")
|
||||
|
||||
|
||||
class UserTopicPreferenceResponse(BaseModel):
|
||||
"""用户兴趣词响应体。"""
|
||||
id: int
|
||||
user_id: int
|
||||
interested_keyword: str
|
||||
created_at: datetime
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class EventMatchSemanticHit(BaseModel):
|
||||
"""语义命中的明细。"""
|
||||
preference_keyword: str
|
||||
topic_keyword: str
|
||||
similarity: float
|
||||
|
||||
|
||||
class MatchedEventResponse(BaseModel):
|
||||
"""推荐事件响应体。"""
|
||||
event_id: int
|
||||
unified_title: str
|
||||
summary: Optional[str]
|
||||
hot_score: int
|
||||
created_at: datetime
|
||||
tags: List[str] = Field(default_factory=list)
|
||||
match_score: float
|
||||
exact_hits: List[str] = Field(default_factory=list)
|
||||
semantic_hits: List[EventMatchSemanticHit] = Field(default_factory=list)
|
||||
|
||||
|
||||
class UserPreferenceRecommendationResponse(BaseModel):
|
||||
"""用户兴趣推荐结果。"""
|
||||
user_id: int
|
||||
total: int
|
||||
data: List[MatchedEventResponse] = Field(default_factory=list)
|
||||
Reference in New Issue
Block a user