43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
"""ORM model for sidebar-menu overrides (菜单管理).
|
|
|
|
Global / shared — there is no ``user_id`` scoping; every account sees the same
|
|
menu layout. The static menu tree (icons / routes / adminOnly) lives in the
|
|
frontend code; this table only stores per-node **overrides** keyed by the static
|
|
node id (or an injected iframe light-app node id ``light-app-<appId>``):
|
|
|
|
- ``parent_id`` — the effective parent node id (NULL = top level). Re-parenting
|
|
a node moves its whole subtree.
|
|
- ``sort_order`` — position among siblings under the effective parent.
|
|
- ``label`` — rename; NULL keeps the code-defined label.
|
|
- ``disabled`` — hide the node (and its subtree) from the sidebar.
|
|
|
|
A node with no row here renders exactly as the code defines it. ``updated_by``
|
|
is audit-only.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import UTC, datetime
|
|
|
|
from sqlalchemy import Boolean, Integer, String
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from deerflow.persistence.base import Base
|
|
from deerflow.persistence.types import BeijingDateTime
|
|
|
|
|
|
class MenuOverrideRow(Base):
|
|
__tablename__ = "menu_overrides"
|
|
|
|
node_id: Mapped[str] = mapped_column(String(128), primary_key=True)
|
|
# Effective parent node id; NULL = top-level menu.
|
|
parent_id: Mapped[str | None] = mapped_column(String(128), index=True)
|
|
sort_order: Mapped[int] = mapped_column(Integer, default=0)
|
|
# Rename override; NULL keeps the code-defined label.
|
|
label: Mapped[str | None] = mapped_column(String(255))
|
|
disabled: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
updated_by: Mapped[str | None] = mapped_column(String(64))
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
BeijingDateTime(), default=lambda: datetime.now(UTC), onupdate=lambda: datetime.now(UTC)
|
|
)
|