test四轮完成的版本,并入了刘盼的老师模块

This commit is contained in:
2026-09-13 19:50:22 +08:00
parent 24b0ad46ec
commit 1e59419dc7
5 changed files with 186 additions and 13 deletions
+34
View File
@@ -0,0 +1,34 @@
from pydantic import BaseModel, Field, ConfigDict
from datetime import datetime
from typing import Optional
# ---------- 请求模型 ----------
class TeacherCreate(BaseModel):
t_no: Optional[str] = Field(None, max_length=20, description="老师编号,不传则自动生成")
t_name: str = Field(..., max_length=50, description="老师姓名")
t_phone: Optional[str] = Field(None, max_length=20, description="电话")
t_email: Optional[str] = Field(None, max_length=20, description="邮箱")
class_id: int = Field(..., description="班级ID")
role: str = Field(..., max_length=50, description="角色")
class TeacherUpdate(BaseModel):
t_no: Optional[str] = Field(None, max_length=20)
t_name: Optional[str] = Field(None, max_length=50)
t_phone: Optional[str] = Field(None, max_length=20)
t_email: Optional[str] = Field(None, max_length=20)
class_id: Optional[int] = None
role: Optional[str] = Field(None, max_length=50)
# ---------- 响应模型 ----------
class TeacherResponse(BaseModel):
t_id: int
t_no: str
t_name: str
class_id: int
role: str
t_phone: Optional[str]
t_email: Optional[str]
model_config = ConfigDict(from_attributes=True)