from typing import List, Optional, Dict
from pydantic import BaseModel, EmailStr, Field
from ..common.base import BaseResponseWithID


class UserListDetailItem(BaseResponseWithID):
    """
    用户列表内明细模型
    """
    id: Optional[str] = Field(default=None, description="唯一标识符")
    username: Optional[str] = Field(None, description="用户名")
    name: Optional[str] = Field(None, description="姓名")
    phone: Optional[str] = Field(None, description="手机号")
    phone_country: Optional[str] = Field(None, description="手机号国家前缀")
    country_code: Optional[str] = Field(None, description="国家编码")
    id_card: Optional[str] = Field(None, description="身份证号")
    status: Optional[str] = Field(None, description="状态")
    email: Optional[EmailStr] = Field(None, description="邮箱地址")
    user_type: str = Field(..., description="用户类型")
    # last_login_at: Optional[str] = Field(None, description="最后登录时间")
    # updated_at: Optional[str] = Field(None, description="更新时间")
    company_id: Optional[str] = Field(None, description="公司id")
    company_name: Optional[str] = Field(None, description="公司名称")
    # created_at: Optional[str] = Field(None, description="创建时间")
    # approval_status: Optional[str] = Field(None, description="审批状态")  # 不再区分审批状态和审批时间
    # approval_time: Optional[str] = Field(None, description="审批通过时间")
    # last_login_ip: Optional[str] = Field(None, description="最后登录ip")
    project_ids: Optional[List[str]] = Field([], description="权限内项目id")
    contract_ids: Optional[List[str]] = Field([], description="权限内合同id")
    phone_hash: Optional[str] = Field(None, description="手机号hash")
    apply_files: Optional[List[Dict]] = Field([],
                                              examples=[
                                                  {"id": "file:001", "name": "文件1",
                                                   "url": "https://example.com/file1.pdf"}
                                              ],
                                              description='申请文件'
                                              )


class UserListResponse(BaseModel):
    """
    用户列表响应模型
    """

    page: int
    page_size: int
    total: int
    list: List[UserListDetailItem]


