"""
标签分类数据库模型
"""
from sqlalchemy import Column, BigInteger, Integer, String, SmallInteger, DateTime, Text
from sqlalchemy.dialects.mysql import CHAR
from datetime import datetime
from app.base.async_mysql_connection import Base
from app.models.base import BaseModel


class TagCategory(BaseModel):
    """标签分类模型 - 分类树结构"""
    __tablename__ = "t_samp_tag_category"

    id = Column(BigInteger, primary_key=True, autoincrement=True, comment="主键ID")
    parent_id = Column(BigInteger, nullable=False, default=0, comment="父级分类ID（0表示根节点）")
    name = Column(String(100), nullable=False, comment="分类名称")
    path = Column(String(500), nullable=False, default="/", comment="分类路径（物化路径），例如 /1/3/9/")
    level = Column(Integer, nullable=False, default=1, comment="分类层级（1=一级，2=二级，依次递增）")
    type = Column(CHAR(50), nullable=False, default="label", comment="类型")
    sort_no = Column(Integer, nullable=False, default=0, comment="同级排序号（越小越靠前）")
    status = Column(SmallInteger, nullable=False, default=1, comment="状态（1=启用，0=禁用）")
    is_deleted = Column(SmallInteger, nullable=False, default=0, comment="是否删除（0=未删除，1=已删除）")

    def __repr__(self):
        return f"<TagCategory {self.id}:{self.name}>"
