from __future__ import annotations

from typing import Any

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
    department: str = ""
    departmentName: str = ""
    position: str = ""
    grade: str = ""
    employeeNo: str = ""
    managerName: str = ""
    location: str = ""
    costCenter: str = ""
    financeOwnerName: str = ""
    riskProfile: dict[str, Any] = Field(default_factory=dict)
    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
