34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
# schemas/cls_mgmt_schema.py
|
|
# 班级管理模块的 Pydantic 模式
|
|
|
|
from datetime import date
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class ClsMgmtBase(BaseModel):
|
|
"""班级公共字段"""
|
|
cls_start_date: date = Field(..., description="开课时间")
|
|
head_tea_id: str = Field(..., max_length=15, description="班主任id")
|
|
lecturer_id: str = Field(..., max_length=15, description="主讲老师id")
|
|
|
|
|
|
class ClsMgmtCreate(ClsMgmtBase):
|
|
"""新增班级时,id(班级编号)必填"""
|
|
id: str = Field(..., max_length=15, description="班级编号(主键)")
|
|
|
|
|
|
class ClsMgmtUpdate(BaseModel):
|
|
"""更新班级信息:仅更新传入的字段"""
|
|
cls_start_date: Optional[date] = Field(default=None, description="开课时间")
|
|
head_tea_id: Optional[str] = Field(default=None, max_length=15, description="班主任id")
|
|
lecturer_id: Optional[str] = Field(default=None, max_length=15, description="主讲老师id")
|
|
|
|
|
|
class ClsMgmtOut(ClsMgmtBase):
|
|
"""班级响应模型(含 id 与软删除标记)"""
|
|
id: str
|
|
is_deleted: int
|
|
|
|
model_config = ConfigDict(from_attributes=True) |