2026-05-15 12:17:46 +08:00
|
|
|
"""
|
|
|
|
|
年度收视目标 Schema — 请求 / 响应模型
|
|
|
|
|
|
|
|
|
|
业务规则:yearly_targets 只增不改,ON CONFLICT DO NOTHING
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from datetime import date
|
|
|
|
|
|
|
|
|
|
from pydantic import BaseModel, ConfigDict
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class YearlyTargetBase(BaseModel):
|
|
|
|
|
year: int
|
|
|
|
|
base_target: float
|
|
|
|
|
stretch_target: float
|
|
|
|
|
issued_date: date | None = None
|
|
|
|
|
notes: str | None = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class YearlyTargetCreate(YearlyTargetBase):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
2026-05-20 11:29:28 +08:00
|
|
|
class YearlyTargetUpdate(BaseModel):
|
|
|
|
|
"""PATCH 时允许只传部分字段,year 不可修改(由 API 层 pop 掉)。"""
|
|
|
|
|
year: int | None = None
|
|
|
|
|
base_target: float | None = None
|
|
|
|
|
stretch_target: float | None = None
|
|
|
|
|
issued_date: date | None = None
|
|
|
|
|
notes: str | None = None
|
2026-05-15 12:17:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class YearlyTargetResponse(YearlyTargetBase):
|
|
|
|
|
id: int
|
|
|
|
|
|
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|