from datetime import datetime
from typing import Optional, Any
from pydantic import BaseModel, Field

class CleaningTaskBase(BaseModel):
    target: str = Field(description="目标(URL/公司名/ID)")
    clean_type: str = Field("auto", description="清洗模式")
    platform: str = Field("auto", description="目标平台")
    proxy: Optional[str] = Field(None, description="代理地址")
    status: str = Field("pending", description="状态: pending/processing/success/fail")
    storage_status: str = Field("unknown", description="存储状态: saved/duplicate/failed/unknown")
    remote_sent: bool = Field(False, description="是否已远程推送")
    result_summary: Optional[Any] = Field(None, description="清洗结果摘要")
    original_data: Optional[Any] = Field(None, description="原始请求数据")
    error_msg: Optional[str] = Field(None, description="错误信息")

class CleaningTaskCreate(CleaningTaskBase):
    pass

class CleaningTaskUpdate(CleaningTaskBase):
    pass

class CleaningTaskOut(CleaningTaskBase):
    id: int
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True
