#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
海报API模型定义 - 使用 camelCase 命名约定
"""

from typing import List, Dict, Any, Optional
from pydantic import BaseModel, Field


class PosterGenerateRequest(BaseModel):
    """海报生成请求模型"""
    templateId: str = Field("vibrant", description="模板ID")
    imageIds: Optional[List[int]] = Field(None, description="图像ID列表")
    posterContent: Optional[Dict[str, Any]] = Field(None, description="海报内容，如果提供则直接使用此内容")
    contentId: Optional[int] = Field(None, description="内容ID，用于AI生成内容")
    productId: Optional[int] = Field(None, description="产品ID，用于AI生成内容")
    scenicSpotId: Optional[int] = Field(None, description="景区ID，用于AI生成内容")
    numVariations: int = Field(3, description="要生成的海报变体数量, 默认为3", ge=1, le=5)
    forceLlmGeneration: bool = Field(False, description="是否强制使用LLM重新生成内容")
    
    class Config:
        json_schema_extra = {
            "example": {
                "templateId": "vibrant",
                "imageIds": [1, 2, 3],
                "numVariations": 3,
                "posterContent": {
                    "title": "直接提供的内容标题",
                    "slogan": "这是一个预先准备好的口号"
                }
            }
        }

class TemplateInfo(BaseModel):
    """模板信息模型"""
    id: str
    name: str
    description: str
    handlerPath: str
    className: str
    isActive: bool

class TemplateListResponse(BaseModel):
    """模板列表响应模型"""
    templates: List[TemplateInfo]
    totalCount: int

class ImageUsageInfo(BaseModel):
    """图像使用信息模型"""
    imageId: int
    usageCount: int
    firstUsedAt: str
    lastUsedAt: str
    usageContext: List[str]

class PosterGenerateResponse(BaseModel):
    """海报生成响应模型"""
    requestId: str
    templateId: str
    resultImagesBase64: List[str] = Field(description="生成的海报图像(base64编码)列表")
    usedImageIds: List[int] = Field(default_factory=list)
    imageUsageInfo: List[ImageUsageInfo] = Field(default_factory=list)
    metadata: Dict[str, Any] = Field(default_factory=dict)

class ImageUsageRequest(BaseModel):
    """图像使用查询请求模型"""
    imageIds: List[int]

class ImageUsageResponse(BaseModel):
    """图像使用情况响应模型"""
    requestId: str
    imageUsageInfo: List[ImageUsageInfo]
    summary: Dict[str, Any] 