from datetime import datetime
from typing import List, Optional

from pydantic import BaseModel, Field


class RequestOAuthRequest(BaseModel):
    open_type: int = Field(
        ...,
        description="开户方式（1=千川，2=广告，3=本地推，4=星图，5=快手代理商，6=巨量星图，7=巨量服务单，8=腾讯服务单，9=腾讯营销K2，10=腾讯营销K3）",
    )


class RequestOAuthResponse(BaseModel):
    auth_url: str = Field(..., description="第三方授权链接")


class UserOAuthOut(BaseModel):
    id: str = Field(..., description="主键")
    account_id: str = Field(..., description="授权账户id")
    account_name: str = Field(..., description="授权账户name")
    account_role: Optional[str] = Field(None, description="授权账户角色")
    account_username: Optional[str] = Field(None, description="授权账户登录账号")
    account_userid: Optional[str] = Field(None, description="授权账户登录账号id")
    user_id: str = Field(..., description="用户id")
    open_type: int = Field(..., description="开户方式（1=千川，2=广告，3=本地推，4=星图，5=快手代理商，6=巨量星图，7=巨量服务单，8=腾讯服务单，9=腾讯营销K2，10=腾讯营销K3）")
    port_type: int = Field(..., description="平台端口（1=巨量，2=磁力，3=巨量星图，4=服务单，5=腾讯）")
    appid: Optional[str] = Field(None, description="授权应用id")
    material_auth_status: bool = Field(False, description="是否敏感物料授权")
    created_at: datetime = Field(..., description="创建时间")
    updated_at: datetime = Field(..., description="更新时间")


class PaginationInfo(BaseModel):
    page: int = Field(..., description="当前页码")
    page_size: int = Field(..., description="每页数量")
    total: int = Field(..., description="总记录数")
    total_pages: int = Field(..., description="总页数")


class OAuthListResponse(BaseModel):
    code: int = Field(0, description="返回码，0表示成功")
    message: str = Field("查询成功", description="返回消息")
    data: List[UserOAuthOut] = Field(..., description="授权列表数据")
    pagination: PaginationInfo = Field(..., description="分页信息")