"""认证模块出入参。""" from __future__ import annotations from datetime import datetime from pydantic import BaseModel, Field from app.schema.common import ORMBase class LoginParams(BaseModel): username: str = Field(..., min_length=2, max_length=50, description="登录名") password: str = Field(..., min_length=4, max_length=64, description="密码") class AccountOut(ORMBase): id: int username: str real_name: str role: str role_text: str advisor_id: int | None = None is_active: bool = True last_login_at: datetime | None = None class TokenOut(BaseModel): access_token: str token_type: str = "Bearer" expires_in: int = Field(..., description="有效期(秒)") account: AccountOut class AccountCreate(BaseModel): username: str = Field(..., min_length=2, max_length=50) password: str = Field(..., min_length=4, max_length=64) real_name: str = Field(..., min_length=1, max_length=30) role: str = Field("advisor", description="admin / advisor / viewer") advisor_id: int | None = None class PasswordChange(BaseModel): old_password: str = Field(..., min_length=4, max_length=64) new_password: str = Field(..., min_length=6, max_length=64, description="至少 6 位")