""" Auth 相关 Pydantic V2 Schema """ from __future__ import annotations import uuid from pydantic import BaseModel, Field # ── 登录请求 ────────────────────────────────────────────── class LoginRequest(BaseModel): username: str = Field(..., min_length=1, max_length=50, examples=["admin"]) password: str = Field(..., min_length=1, max_length=128, examples=["123456"]) # ── Token 响应 ──────────────────────────────────────────── class TokenResponse(BaseModel): access_token: str token_type: str = "bearer" # ── 当前用户信息(从 JWT 解析 + DB 查表组合而来)────────── class CurrentUserPayload(BaseModel): """注入到 Dependency 中的用户权限上下文""" user_id: uuid.UUID username: str real_name: str | None = None dept_id: uuid.UUID | None = None dept_name: str | None = None role_id: uuid.UUID | None = None role_name: str | None = None data_scope: str = "self" # all / dept_and_sub / self menu_keys: list[str] = Field(default_factory=list) # ── 修改密码请求 ──────────────────────────────────── class UpdatePasswordRequest(BaseModel): old_password: str = Field(..., min_length=1, max_length=128) new_password: str = Field(..., min_length=6, max_length=128, description="新密码至少6位")