from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime

# 作品创建
class WorkCreate(BaseModel):
    title: str
    category: str
    designer: str
    level: int = 1
    level_text: str = "设计爱好者"
    price: float  # 下载价格
    description: Optional[str] = None
    tags: Optional[str] = None

# 作品更新
class WorkUpdate(BaseModel):
    title: Optional[str] = None
    price: Optional[float] = None
    description: Optional[str] = None

# 作品响应
class WorkResponse(BaseModel):
    id: int
    title: str
    category: str
    designer: str
    level: int
    level_text: str
    
    thumbnail_image: Optional[str]
    watermarked_image: Optional[str]
    
    price: float
    views: int
    downloads: int
    collects: int
    
    description: Optional[str]
    tags: Optional[str]
    
    created_at: datetime
    
    class Config:
        from_attributes = True

# 作品列表响应
class WorkListResponse(BaseModel):
    total: int
    items: List[WorkResponse]
