#!/usr/bin/env python # -*- coding: utf-8 -*- from datetime import datetime from typing import Optional, Any, List from pydantic import Field from pydantic.main import BaseModel from schemas.base import DetailMixin class SwaggerToken(BaseModel): access_token: str token_type: str class Token(DetailMixin): pass class TokenPayload(BaseModel): sub: Optional[Any] = None class AdminLoginInfo(BaseModel): username: str = Field(..., description="用户名") password: str = Field(..., description="密码") class UserLoginInfo(BaseModel): utype: int = Field(..., description="用户类型,1=教师,2=学生") username: str = Field(..., description="用户名") password: str = Field(..., description="密码") class UserProfileItem(BaseModel): id: int = Field(..., description="用户ID") username: str = Field(..., description="账号") name: str = Field(..., description="姓名") role: Optional[str] = Field(None, description="职务") pcodes: Optional[List[Any]] = [] class Config: orm_mode = True anystr_strip_whitespace = True class CurrentUserProfile(DetailMixin): data: Optional[UserProfileItem] = None class LastLoginInfo(BaseModel): is_first_login: Optional[bool] = Field(None, description="是否首次登录") last_login_ip: Optional[str] = Field(None, description="最后登录IP") last_login_time: Optional[datetime] = Field(None, description="最后登录时间") class EditPwdInfo(BaseModel): code: str = Field(..., description="验证码") oldpwd: str = Field(..., description="原始密码") newpwd: str = Field(..., max_length=6, description="新密码") class Config: anystr_strip_whitespace = True class UpdatePassword(BaseModel): password: str is_first_login: bool = None