from pydantic import BaseModel, Field


class AttachmentTypeIn(BaseModel):
    code: str = Field(..., max_length=80)
    label: str = Field(..., max_length=160)
    description: str | None = Field(None, max_length=500)
    sort_order: int = 0
    is_active: bool = True


class AttachmentTypeOut(AttachmentTypeIn):
    id: int
    tenant_id: int

    model_config = {"from_attributes": True}


class ProductAttachmentIn(BaseModel):
    type_id: int
    title: str | None = Field(None, max_length=200)
    file_url: str = Field(..., max_length=500)
    mime_type: str | None = Field(None, max_length=120)
    file_size: int | None = None
    sort_order: int = 0
    is_active: bool = True


class ProductAttachmentOut(ProductAttachmentIn):
    id: int
    tenant_id: int
    product_id: int
    type_code: str | None = None
    type_label: str | None = None

    model_config = {"from_attributes": True}


class StoreProductAttachmentOut(BaseModel):
    id: int
    type_code: str
    type_label: str
    title: str
    file_url: str
    mime_type: str | None = None
    file_size: int | None = None
    sort_order: int = 0
