aaa
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
# scheme/teachers.py
|
||||
# 本文件定义老师模块用到的 Pydantic 模型
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
# 新增教师的请求体模型 ----------
|
||||
class TeacherCreate(BaseModel):
|
||||
teacher_name: str = Field(..., description="老师姓名")
|
||||
gender: Optional[str] = Field(None, description="性别")
|
||||
phone: Optional[str] = Field(None, min_length=11,description="联系电话")
|
||||
is_headteacher: int = Field(0, ge=0, le=1, description="1-班主任 0-任课老师")
|
||||
|
||||
|
||||
class TeacherUpdate(BaseModel):
|
||||
teacher_name: Optional[str] = None
|
||||
gender: Optional[str] = None
|
||||
phone: Optional[str] = Field(None,min_length=11,description="联系电话")
|
||||
is_headteacher: Optional[int] = Field(None, ge=0, le=1)
|
||||
|
||||
|
||||
# 响应体模型
|
||||
class TeacherResponse(BaseModel):
|
||||
teacher_id: int
|
||||
teacher_name: str
|
||||
gender: Optional[str] = None
|
||||
phone: Optional[str] = None
|
||||
is_headteacher: int
|
||||
# flag: int
|
||||
#响应模型读取 SQLAlchemy ORM 对象属性 的配置
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class TeacherListResponse(BaseModel):
|
||||
total: int
|
||||
items: list[TeacherResponse]
|
||||
Reference in New Issue
Block a user