"""
基礎 Schema 類別
"""
from datetime import datetime
from pydantic import BaseModel, ConfigDict


class BaseSchema(BaseModel):
    """基礎 Schema"""

    model_config = ConfigDict(
        from_attributes=True,  # 支援從 ORM 模型轉換
        use_enum_values=True,   # 使用 Enum 的值
    )


class TimestampSchema(BaseSchema):
    """帶時間戳的 Schema"""

    created_at: datetime
    updated_at: datetime


class PaginationParams(BaseModel):
    """分頁參數"""

    page: int = 1
    page_size: int = 20

    model_config = ConfigDict(
        json_schema_extra={
            "example": {
                "page": 1,
                "page_size": 20
            }
        }
    )


class PaginatedResponse(BaseModel):
    """分頁響應"""

    total: int
    page: int
    page_size: int
    total_pages: int
    items: list

    model_config = ConfigDict(from_attributes=True)
