"""Ozon 类目字典缓存(可重建,不作为业务真源)。""" from __future__ import annotations from datetime import datetime from sqlalchemy import BigInteger, Boolean, DateTime, Integer, String, Text, func from sqlalchemy.orm import Mapped, mapped_column from db import Base class CategoryTree(Base): __tablename__ = "category_tree" description_category_id: Mapped[int] = mapped_column(BigInteger, primary_key=True) parent_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True, index=True) category_name: Mapped[str] = mapped_column(String(255), default="") type_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True) type_name: Mapped[str] = mapped_column(String(255), default="") disabled: Mapped[bool] = mapped_column(Boolean, default=False) level: Mapped[int] = mapped_column(Integer, default=0) lang: Mapped[str] = mapped_column(String(8), default="DEFAULT") updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now()) class CategoryAttribute(Base): __tablename__ = "category_attributes" description_category_id: Mapped[int] = mapped_column(BigInteger, primary_key=True) type_id: Mapped[int] = mapped_column(BigInteger, primary_key=True) attribute_id: Mapped[int] = mapped_column(BigInteger, primary_key=True) name: Mapped[str] = mapped_column(String(255), default="") description: Mapped[str] = mapped_column(Text, default="") type: Mapped[str] = mapped_column(String(32), default="") dictionary_id: Mapped[int] = mapped_column(BigInteger, default=0) group_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True) group_name: Mapped[str] = mapped_column(String(255), default="") is_required: Mapped[bool] = mapped_column(Boolean, default=False) is_aspect: Mapped[bool] = mapped_column(Boolean, default=False) is_collection: Mapped[bool] = mapped_column(Boolean, default=False) max_value_count: Mapped[int] = mapped_column(Integer, default=0) attribute_complex_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True) complex_is_collection: Mapped[bool] = mapped_column(Boolean, default=False) category_dependent: Mapped[bool] = mapped_column(Boolean, default=False) lang: Mapped[str] = mapped_column(String(8), default="DEFAULT") updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now()) class AttributeValue(Base): __tablename__ = "attribute_values" id: Mapped[int] = mapped_column(BigInteger, primary_key=True) attribute_id: Mapped[int] = mapped_column(BigInteger, primary_key=True) description_category_id: Mapped[int] = mapped_column(BigInteger, primary_key=True) type_id: Mapped[int] = mapped_column(BigInteger, primary_key=True) value: Mapped[str] = mapped_column(String(512), default="") picture: Mapped[str] = mapped_column(Text, default="") info: Mapped[str] = mapped_column(Text, default="") lang: Mapped[str] = mapped_column(String(8), default="DEFAULT") updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())