27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
from sqlalchemy import String, Integer, Text, SmallInteger
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
from sqlalchemy import Enum, UniqueConstraint
|
|
from .base import Base, TimestampMixin, MYSQL_TABLE_ARGS
|
|
from .enums import ParamTypeEnum, StatusEnum
|
|
|
|
|
|
class SystemParam(Base, TimestampMixin):
|
|
__tablename__ = "sys_param"
|
|
__table_args__ = (
|
|
UniqueConstraint("param_key", name="uk_param_key"),
|
|
MYSQL_TABLE_ARGS,
|
|
)
|
|
|
|
param_id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
param_key: Mapped[str] = mapped_column(String(100), nullable=False)
|
|
param_value: Mapped[str] = mapped_column(Text, nullable=False)
|
|
param_type: Mapped[ParamTypeEnum] = mapped_column(
|
|
Enum(ParamTypeEnum, native_enum=False, values_callable=lambda x: [e.value for e in x]),
|
|
default=ParamTypeEnum.STRING,
|
|
nullable=False,
|
|
)
|
|
status: Mapped[int] = mapped_column(Integer, default=StatusEnum.ENABLED, nullable=False)
|
|
# Changed Boolean to SmallInteger
|
|
is_system: Mapped[int] = mapped_column(SmallInteger, default=0, nullable=False)
|
|
description: Mapped[str | None] = mapped_column(Text)
|