import uuid
from datetime import datetime

from pydantic import BaseModel, Field


class SchemaAdviseRequest(BaseModel):
    brand_id: uuid.UUID = Field(..., description="品牌ID")
    target_url: str | None = Field(None, description="目标页面URL")
    focus_dimensions: list[str] | None = Field(None, description="聚焦的诊断维度")


class SchemaSuggestionResponse(BaseModel):
    id: uuid.UUID = Field(..., description="建议ID")
    brand_id: uuid.UUID = Field(..., description="品牌ID")
    schema_type: str = Field(..., description="Schema类型: Organization/Product/FAQPage/Article/LocalBusiness")
    target_url: str | None = Field(None, description="目标页面URL")
    json_ld_template: dict = Field(..., description="JSON-LD模板")
    json_ld_filled: dict | None = Field(None, description="填充后的JSON-LD")
    priority: str = Field(default="medium", description="优先级: high/medium/low")
    status: str = Field(default="pending", description="状态: pending/applied/dismissed")
    diagnosis_dimensions: dict | None = Field(None, description="诊断维度数据")
    implementation_difficulty: str = Field(default="medium", description="实施难度: easy/medium/hard")
    estimated_impact: str | None = Field(None, description="预期影响描述")
    validation_errors: dict | None = Field(None, description="验证错误信息")
    created_at: datetime = Field(..., description="创建时间")
    updated_at: datetime = Field(..., description="更新时间")

    class Config:
        from_attributes = True


class SchemaSuggestionList(BaseModel):
    suggestions: list[SchemaSuggestionResponse] = Field(default_factory=list, description="建议列表")
    total: int = Field(..., description="总数")


class SchemaValidationResult(BaseModel):
    is_valid: bool = Field(..., description="是否有效")
    errors: list[str] = Field(default_factory=list, description="错误列表")
    warnings: list[str] = Field(default_factory=list, description="警告列表")


class SchemaStatusUpdateRequest(BaseModel):
    status: str = Field(..., description="新状态: pending/applied/dismissed")
