from __future__ import annotations

from pydantic import BaseModel, EmailStr, Field


class LoginRequest(BaseModel):
    username: str = Field(min_length=1, max_length=255)
    password: str = Field(min_length=1, max_length=128)


class AuthUserRead(BaseModel):
    username: str
    name: str
    role: str
    roleCodes: list[str] = Field(default_factory=list)
    email: EmailStr | str
    avatar: str
    isAdmin: bool = False


class LoginResponse(BaseModel):
    ok: bool = True
    detail: str = "登录成功。"
    user: AuthUserRead
