mirror of
https://github.com/stardrophere/InsightRadar.git
synced 2026-06-05 21:57:50 +08:00
73 lines
2.5 KiB
Python
73 lines
2.5 KiB
Python
from datetime import datetime
|
||
from typing import List, Optional
|
||
|
||
from pydantic import BaseModel, ConfigDict, Field
|
||
|
||
# AI辅助生成:deepseek-v3-2,2026年3月20日
|
||
|
||
# ==========================================
|
||
# 推送时间表 (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)
|