from pydantic import BaseModel, Field
from typing import Optional, List
from datetime import datetime
from uuid import UUID

class BookCategoryBase(BaseModel):
    name: str = Field(..., min_length=1, max_length=200)
    description: Optional[str] = None
    sort_order: int = Field(0, ge=0)

class CreateBookCategoryRequest(BookCategoryBase):
    book_id: UUID

class UpdateBookCategoryRequest(BaseModel):
    name: Optional[str] = Field(None, min_length=1, max_length=200)
    description: Optional[str] = None
    sort_order: Optional[int] = Field(None, ge=0)

class BookCategoryResponse(BookCategoryBase):
    id: UUID
    book_id: UUID
    created_at: datetime
    updated_at: Optional[datetime]
    document_count: int = 0  # 포함된 문서 수

    class Config:
        from_attributes = True

class UpdateDocumentOrderRequest(BaseModel):
    document_orders: List[dict] = Field(..., description="문서 ID와 순서 정보")
    # 예: [{"document_id": "uuid", "sort_order": 1}, ...]
