"""
通用響應 Schemas
"""
from typing import Optional, Any, Generic, TypeVar
from pydantic import BaseModel, Field

T = TypeVar('T')


class ResponseModel(BaseModel, Generic[T]):
    """通用響應模型"""

    success: bool = Field(True, description="操作是否成功")
    message: Optional[str] = Field(None, description="響應訊息")
    data: Optional[T] = Field(None, description="響應數據")


class ErrorResponse(BaseModel):
    """錯誤響應"""

    success: bool = Field(False, description="操作是否成功")
    message: str = Field(..., description="錯誤訊息")
    error_code: Optional[str] = Field(None, description="錯誤代碼")
    details: Optional[Any] = Field(None, description="錯誤詳情")


class MessageResponse(BaseModel):
    """簡單訊息響應"""

    message: str = Field(..., description="響應訊息")


class SuccessResponse(BaseModel):
    """成功響應"""

    success: bool = Field(True, description="操作是否成功")
    message: str = Field(..., description="成功訊息")
