1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- from typing import List, Optional, Union, Any, Dict
- from pydantic import BaseModel, Field
- from schemas.base import Datetime2Str, ListMixin, DetailMixin
- class TeacherItem(BaseModel):
- id: int
- name: str
- sex: Optional[int] = None
- age: Optional[int] = None
- phone: Optional[str] = None
- school_id: Optional[int] = None
- school_name: Optional[str] = None
- grade_id: Optional[int] = None
- grade_name: Optional[str] = None
- class_id: Optional[int] = None
- class_name: Optional[str] = None
- role_id: Optional[int] = None
- role_name: Optional[str] = None
- subject_id: Optional[int] = None
- subject: Optional[str] = None
- created_at: Optional[Datetime2Str] = None
- class Config:
- orm_mode = True
- class TeacherList(ListMixin):
- data: List[TeacherItem] = []
- class TeacherDetail(DetailMixin):
- data: Union[Dict[str, Any], TeacherItem] = None
- class NewTeacher(BaseModel):
- name: str = Field(..., max_lenght=20, description="教师名称")
- sex: int = Field(0, ge=0, le=1, description="性别, 0:女,1:男")
- age: int = Field(0, description="年龄")
- phone: str = Field(..., max_length=11, description="手机号")
- school_id: int = Field(..., alias="sid", description="学校ID")
- grade_id: int = Field(..., alias="gid", description="年级ID")
- class_id: str = Field(..., alias="cid", description="班级ID,用逗号分隔")
- role_id: int = Field(..., alias="rid", description="职务ID")
- subject: str = Field(..., max_length=10, alias="sub", description="任教学科")
- class Config:
- anystr_strip_whitespace = True
- class TeacherInDB(NewTeacher):
- role_name: str = Field(..., description="角色名称,前端忽略,后端处理")
- class_name: str = Field(..., description="班级名称,前端忽略,后端处理")
- grade_name: str = Field(..., description="年级名称,前端忽略,后端处理")
- school_name: str = Field(..., description="学校名称,前端忽略,后端处理")
- username: str = Field(..., description="用户名")
- password: str = Field(..., max_length=64, description="密码")
- creator_id: int = Field(..., description="创建人ID")
- creator_name: str = Field(..., description="创建人姓名")
- editor_id: int = Field(..., description="最后编辑人ID")
- editor_name: str = Field(..., description="最后编辑人姓名")
- class UpdateTeacher(BaseModel):
- username: Optional[str] = Field(None, max_length=11, description="用户名")
- name: Optional[str] = Field(None, max_lenght=20, description="教师名称")
- sex: Optional[int] = Field(None, ge=0, le=1, description="性别, 0:女,1:男")
- age: Optional[int] = Field(None, description="年龄")
- phone: Optional[str] = Field(None, max_length=11, description="手机号")
- school_id: Optional[int] = Field(None, alias="sid", description="学校ID")
- school_name: Optional[str] = Field(None, description="学校名称,前端忽略,后端处理")
- grade_id: Optional[int] = Field(None, alias="gid", description="年级ID")
- grade_name: Optional[str] = Field(None, description="年级名称,前端忽略,后端处理")
- class_id: Optional[str] = Field(None, alias="cid", description="班级ID")
- class_name: Optional[str] = Field(None, description="班级名称,前端忽略,后端处理")
- role_id: Optional[int] = Field(None, alias="rid", description="职务ID")
- role_name: Optional[str] = Field(None, description="角色名称,前端忽略,后端处理")
- subject: Optional[str] = Field(None,
- max_length=10,
- alias="sub",
- description="任教学科")
- editor_id: int = Field(None, description="最后编辑人ID,后端戳i,前端忽略")
- editor_name: str = Field(None, description="最后编辑人姓名,后端戳i,前端忽略")
- class Config:
- anystr_strip_whitespace = True
|