from pydantic import BaseModel, Field, field_validator from typing import Optional, List from datetime import date class ClassCreate(BaseModel): cid : int= Field(...,description="班级编号") class_name : str= Field(...,min_length=1, max_length=50, description="班级名称") start_time:date headteacher : str=Field(...,min_length=1, max_length=50,description="班主任") flag:int class ClassUpdate(BaseModel): class_name:Optional[str]=Field(None,min_length=1, max_length=50) start_time: Optional[date] = None headteacher: Optional[str] = Field(None, min_length=1, max_length=50) #响应体参数 class ClassResponse(BaseModel): cid : int class_name : str start_time : date headteacher : str flag : int class Config: from_attributes = True class ClassListResponse(BaseModel): total: int items: list[ClassResponse]