d4a13ece17
ruff --select F401 --fix 自动修复: - deps.py: user_crud - caption.py: ApiResponse, VolcengineCaptionService - points.py: UTC - tasks.py: json - voice.py: asyncio - main.py: init_db - broll_category.py: Text, ARRAY
64 lines
1.8 KiB
Python
64 lines
1.8 KiB
Python
"""
|
|
素材分类模型
|
|
============
|
|
|
|
装修工序的三级分类体系,支持通过 parent_id 链式关联实现无限层级。
|
|
|
|
层级定义:
|
|
- level=1:一级分类(装修大阶段),如 前期准备类、水电隐蔽类
|
|
- level=2:二级分类(具体工序),如 防水施工、电路施工
|
|
- level=3:三级分类(具体场景),如 卫生间基层清理-防水施工
|
|
"""
|
|
|
|
from sqlalchemy import BigInteger, ForeignKey, String
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.models.base import BaseModelBigInt
|
|
|
|
|
|
class BrollCategory(BaseModelBigInt):
|
|
"""空镜素材分类"""
|
|
|
|
__tablename__ = "mjk_categories"
|
|
|
|
slug: Mapped[str] = mapped_column(
|
|
String(128),
|
|
unique=True,
|
|
nullable=False,
|
|
comment="分类标识符,URL友好格式",
|
|
)
|
|
|
|
name: Mapped[str] = mapped_column(
|
|
String(256),
|
|
nullable=False,
|
|
comment="分类中文名称,三级分类直接对应 scene 标准化后的值",
|
|
)
|
|
|
|
parent_id: Mapped[int | None] = mapped_column(
|
|
BigInteger,
|
|
ForeignKey("mjk_categories.id"),
|
|
nullable=True,
|
|
comment="父分类ID,NULL 表示根分类(一级)",
|
|
)
|
|
|
|
level: Mapped[int] = mapped_column(
|
|
BigInteger,
|
|
default=1,
|
|
nullable=False,
|
|
comment="层级:1=一级(大阶段),2=二级(工序),3=三级(场景)",
|
|
)
|
|
|
|
sort_order: Mapped[int] = mapped_column(
|
|
BigInteger,
|
|
default=0,
|
|
nullable=False,
|
|
comment="排序权重,装修流程有先后顺序",
|
|
)
|
|
|
|
status: Mapped[str] = mapped_column(
|
|
String(16),
|
|
default="active",
|
|
nullable=False,
|
|
comment="状态:active(启用)/ disabled(停用)/ deleted(软删除)",
|
|
)
|