feat: 后端 CRUD 完成(episodes + yearly_targets + users 管理 API)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
认证相关 Pydantic Schema — 请求 / 响应模型
|
||||
"""
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
from app.models.user import UserRole
|
||||
|
||||
@@ -21,5 +21,4 @@ class UserResponse(BaseModel):
|
||||
profile_text: str | None = None
|
||||
is_active: bool = True
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
@@ -0,0 +1,41 @@
|
||||
"""
|
||||
节目期次 Schema — 请求 / 响应模型
|
||||
"""
|
||||
|
||||
from datetime import date
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
from app.models.user import UserRole
|
||||
|
||||
|
||||
class EpisodeBase(BaseModel):
|
||||
episode_number: int
|
||||
program_name: str
|
||||
air_date: date
|
||||
editor_id: int | None = None
|
||||
editor_name_snapshot: str
|
||||
audience_share: float | None = None
|
||||
audience_rating: float | None = None
|
||||
is_rerun: bool = False
|
||||
original_episode_id: int | None = None
|
||||
is_time_sensitive: bool = False
|
||||
is_outdoor_shoot: bool = False
|
||||
outdoor_contact_person: str | None = None
|
||||
outdoor_contact_info: str | None = None
|
||||
lead_source: str | None = None
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class EpisodeCreate(EpisodeBase):
|
||||
pass
|
||||
|
||||
|
||||
class EpisodeUpdate(EpisodeBase):
|
||||
pass
|
||||
|
||||
|
||||
class EpisodeResponse(EpisodeBase):
|
||||
id: int
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
@@ -0,0 +1,33 @@
|
||||
"""
|
||||
用户管理 Schema — 管理员 CRUD(仅 zhipianren 可用)
|
||||
"""
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
from app.models.user import UserRole
|
||||
|
||||
|
||||
class UserCreate(BaseModel):
|
||||
username: str
|
||||
display_name: str
|
||||
password: str
|
||||
role: UserRole
|
||||
profile_text: str | None = None
|
||||
|
||||
|
||||
class UserUpdate(BaseModel):
|
||||
display_name: str | None = None
|
||||
role: UserRole | None = None
|
||||
profile_text: str | None = None
|
||||
is_active: bool | None = None
|
||||
|
||||
|
||||
class UserResponse(BaseModel):
|
||||
id: int
|
||||
username: str
|
||||
display_name: str
|
||||
role: UserRole
|
||||
profile_text: str | None = None
|
||||
is_active: bool = True
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
@@ -0,0 +1,31 @@
|
||||
"""
|
||||
年度收视目标 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
|
||||
|
||||
|
||||
class YearlyTargetUpdate(YearlyTargetBase):
|
||||
pass
|
||||
|
||||
|
||||
class YearlyTargetResponse(YearlyTargetBase):
|
||||
id: int
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
Reference in New Issue
Block a user