from datetime import datetime
from typing import List, Optional

from pydantic import BaseModel, Field


class OpenTypeCreate(BaseModel):
    type_name: str = Field(..., description="标题名称")
    open_type: int = Field(..., description="开户方式id")
    description: Optional[str] = Field(None, description="开户方式描述")
    thumb: Optional[str] = Field(None, description="缩略图")


class OpenTypeUpdate(BaseModel):
    type_name: Optional[str] = Field(None, description="标题名称")
    open_type: Optional[int] = Field(None, description="开户方式id")
    description: Optional[str] = Field(None, description="开户方式描述")
    thumb: Optional[str] = Field(None, description="缩略图")


class OpenTypeOut(BaseModel):
    id: str = Field(..., description="主键")
    type_name: str = Field(..., description="标题名称")
    open_type: int = Field(..., description="开户方式id")
    description: Optional[str] = Field(None, description="开户方式描述")
    thumb: Optional[str] = Field(None, 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 OpenTypeListResponse(BaseModel):
    code: int = Field(0, description="返回码，0表示成功")
    message: str = Field("查询成功", description="返回消息")
    data: List[OpenTypeOut] = Field(..., description="开户方式列表")
    pagination: PaginationInfo = Field(..., description="分页信息")


class OpenTypeResponse(BaseModel):
    code: int = Field(0, description="返回码，0表示成功")
    message: str = Field("操作成功", description="返回消息")
    data: Optional[OpenTypeOut] = Field(None, description="开户方式信息")