#!/usr/bin/env python # -*- coding: utf-8 -*- from datetime import datetime from typing import List from typing import Optional from pydantic import Field from pydantic.main import BaseModel from schemas.base import ListMixin, DetailMixin, Datetime2Str class CreateAdminUser(BaseModel): username: str = Field(..., max_length=64) password: str = Field(..., max_length=64) phone: str = Field(..., max_length=32) name: str = Field(None, max_length=32) role_id: int is_active: bool = None last_login_time: Optional[datetime] = Field(datetime.now()) last_login_ip: Optional[str] = Field("", max_length=15) class UpdateAdminUser(BaseModel): phone: Optional[str] = Field(None, max_length=32, description="手机号") name: Optional[str] = Field(None, max_length=32, description="姓名") is_active: Optional[bool] = Field(None, description="是否激活") class AdminUserInfo(BaseModel): id: Optional[int] = None username: str = Field(None, max_length=64) phone: str = Field(None, max_length=32) name: str = Field(None, max_length=32) role_id: int = Field(None) is_active: bool = None last_login_time: Datetime2Str = None last_login_ip: str = Field(None, max_length=15) creator_name: Optional[str] = None created_at: Datetime2Str = None class Config: orm_mode = True class AdminUserDetail(DetailMixin): data: Optional[AdminUserInfo] = None class AdminUserList(ListMixin): data: List[AdminUserInfo] = []