feat: a few tabs for module
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
import enum
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from sqlalchemy import Table, Column, ForeignKey
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
@ -31,7 +32,6 @@ class BuiltInModule(BaseModel):
|
||||
key: Mapped[str] = mapped_column(unique=True)
|
||||
label: Mapped[str] = mapped_column()
|
||||
description: Mapped[str] = mapped_column()
|
||||
icon_name: Mapped[Optional[str]] = mapped_column(unique=True)
|
||||
is_deleted: Mapped[bool] = mapped_column(default=False)
|
||||
|
||||
depends_on: Mapped[list["BuiltInModule"]] = relationship(
|
||||
@ -56,3 +56,24 @@ class BuiltInModule(BaseModel):
|
||||
back_populates="built_in_modules",
|
||||
lazy="noload",
|
||||
)
|
||||
|
||||
tabs: Mapped[list["BuiltInModuleTab"]] = relationship(
|
||||
lazy="immediate", backref="module", cascade="all, delete-orphan"
|
||||
)
|
||||
|
||||
|
||||
class DeviceType(enum.StrEnum):
|
||||
MOBILE = "mobile"
|
||||
DESKTOP = "desktop"
|
||||
BOTH = "both"
|
||||
|
||||
|
||||
class BuiltInModuleTab(BaseModel):
|
||||
__tablename__ = "built_in_module_tab"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
key: Mapped[str] = mapped_column(unique=True)
|
||||
label: Mapped[str] = mapped_column()
|
||||
icon_name: Mapped[str] = mapped_column()
|
||||
module_id: Mapped[int] = mapped_column(ForeignKey("built_in_modules.id"))
|
||||
device: Mapped[DeviceType] = mapped_column(default=DeviceType.BOTH)
|
||||
|
||||
@ -3,13 +3,21 @@ from schemas.base import BaseSchema
|
||||
# region Entity
|
||||
|
||||
|
||||
class BuiltInModuleTabSchema(BaseSchema):
|
||||
id: int
|
||||
key: str
|
||||
label: str
|
||||
icon_name: str
|
||||
device: str
|
||||
|
||||
|
||||
class BuiltInModuleSchema(BaseSchema):
|
||||
id: int
|
||||
key: str
|
||||
label: str
|
||||
icon_name: str
|
||||
description: str
|
||||
depends_on: list["BuiltInModuleSchema"]
|
||||
tabs: list[BuiltInModuleTabSchema]
|
||||
|
||||
|
||||
# endregion
|
||||
|
||||
Reference in New Issue
Block a user