import enum

from sqlalchemy import Boolean, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column

from app.models.base import BaseModel


class CategoryStatus(str, enum.Enum):
    ACTIVE = "active"
    HIDDEN = "hidden"


class ProductCategory(BaseModel):
    """产品大分类。如：云服务器 / 虚拟主机 / 域名 / SSL 证书。"""

    __tablename__ = "product_categories"

    slug: Mapped[str] = mapped_column(String(64), unique=True, index=True, nullable=False)
    name: Mapped[str] = mapped_column(String(100), nullable=False)
    description: Mapped[str | None] = mapped_column(Text, nullable=True)
    icon: Mapped[str | None] = mapped_column(String(64), nullable=True, comment="lucide 图标名或图片 URL")
    sort_order: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
    status: Mapped[CategoryStatus] = mapped_column(
        String(16),
        default=CategoryStatus.ACTIVE.value,
        nullable=False,
    )
    is_featured: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
    featured_label: Mapped[str] = mapped_column(String(24), default="推荐", nullable=False)
