"""
用户相关 Schema
===============
"""

from datetime import datetime
from uuid import UUID

from pydantic import BaseModel, Field


class UserInfo(BaseModel):
    """用户信息（对外暴露）"""

    id: UUID = Field(..., description="用户 ID")
    nickname: str = Field(default="", description="用户昵称")
    avatar: str = Field(default="", description="头像 URL")
    mobile: str = Field(..., description="手机号（已脱敏）")


class UserProfileResponse(BaseModel):
    """用户个人资料响应"""

    id: UUID = Field(..., description="用户 ID")
    mobile: str = Field(..., description="手机号")
    nickname: str | None = Field(None, description="昵称")
    avatar: str = Field(default="", description="头像 URL")
    status: str = Field(..., description="账号状态")
    source: str = Field(..., description="注册来源")
    last_login_at: datetime | None = Field(None, description="最后登录时间")
    created_at: datetime = Field(..., description="注册时间")

    class Config:
        from_attributes = True


class UpdateNicknameRequest(BaseModel):
    """修改昵称请求"""

    nickname: str = Field(..., min_length=1, max_length=20, description="新昵称，1-20个字符")
