global_tree_category.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from __future__ import annotations
  2. from datetime import datetime
  3. from sqlalchemy import BigInteger, Integer, String, Text, UniqueConstraint, func
  4. from sqlalchemy.orm import Mapped, mapped_column
  5. from supply_infra.db.base import Base
  6. class GlobalTreeCategory(Base):
  7. """全局树分类 — 从 ODPS public_pattern_mining_category 同步。"""
  8. __tablename__ = "global_tree_category"
  9. __table_args__ = (UniqueConstraint("source_id", name="uk_source_id"),)
  10. id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
  11. name: Mapped[str | None] = mapped_column(String(128), nullable=True, comment="名称")
  12. description: Mapped[str | None] = mapped_column(Text, nullable=True, comment="描述")
  13. level: Mapped[int | None] = mapped_column(Integer, nullable=True, comment="层级")
  14. parent_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True, comment="父节点")
  15. source_id: Mapped[int] = mapped_column(BigInteger, nullable=False, comment="hive表id")
  16. source_parent_id: Mapped[int] = mapped_column(BigInteger, nullable=False, comment="hive表父id")
  17. is_delete: Mapped[int] = mapped_column(Integer, default=0, nullable=False, comment="是否删除0-正常 1-删除")
  18. create_time: Mapped[datetime | None] = mapped_column(
  19. nullable=True,
  20. server_default=func.now(),
  21. comment="创建时间",
  22. )
  23. update_time: Mapped[datetime] = mapped_column(
  24. nullable=False,
  25. server_default=func.now(),
  26. onupdate=func.now(),
  27. comment="更新时间",
  28. )