36 lines
1.5 KiB
Python
36 lines
1.5 KiB
Python
from sqlalchemy import String, Integer, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
from sqlalchemy import Enum, UniqueConstraint
|
|
from .base import Base, TimestampMixin, MYSQL_TABLE_ARGS
|
|
from .enums import StatusEnum
|
|
|
|
|
|
class DictType(Base, TimestampMixin):
|
|
__tablename__ = "sys_dict_type"
|
|
__table_args__ = (
|
|
UniqueConstraint("type_code", name="uk_dict_type_code"),
|
|
MYSQL_TABLE_ARGS,
|
|
)
|
|
|
|
dict_type_id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
type_code: Mapped[str] = mapped_column(String(50), nullable=False)
|
|
type_name: Mapped[str] = mapped_column(String(50), nullable=False)
|
|
status: Mapped[int] = mapped_column(Integer, default=StatusEnum.ENABLED, nullable=False)
|
|
remark: Mapped[str | None] = mapped_column(Text)
|
|
|
|
|
|
class DictItem(Base, TimestampMixin):
|
|
__tablename__ = "sys_dict_item"
|
|
__table_args__ = (
|
|
UniqueConstraint("type_code", "item_value", name="uk_dict_item"),
|
|
MYSQL_TABLE_ARGS,
|
|
)
|
|
|
|
dict_item_id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
type_code: Mapped[str] = mapped_column(String(50), nullable=False, index=True)
|
|
item_label: Mapped[str] = mapped_column(String(100), nullable=False)
|
|
item_value: Mapped[str] = mapped_column(String(100), nullable=False)
|
|
sort_order: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
|
|
status: Mapped[int] = mapped_column(Integer, default=StatusEnum.ENABLED, nullable=False)
|
|
remark: Mapped[str | None] = mapped_column(Text)
|