2026-05-15 11:47:29 +08:00
|
|
|
from sqlalchemy import DateTime, Integer, String, func
|
2026-05-14 13:51:06 +08:00
|
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
|
|
|
|
|
|
from backend.app.db import Base
|
|
|
|
|
from backend.app.models.base import TimestampMixin
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class User(TimestampMixin, Base):
|
|
|
|
|
__tablename__ = "sys_user"
|
|
|
|
|
|
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
|
|
|
username: Mapped[str] = mapped_column(String(64), unique=True, index=True)
|
|
|
|
|
password_hash: Mapped[str] = mapped_column(String(255))
|
|
|
|
|
real_name: Mapped[str] = mapped_column(String(64))
|
|
|
|
|
mobile: Mapped[str] = mapped_column(String(32), default="")
|
|
|
|
|
role_id: Mapped[int] = mapped_column(Integer, index=True)
|
|
|
|
|
status: Mapped[int] = mapped_column(Integer, default=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Role(TimestampMixin, Base):
|
|
|
|
|
__tablename__ = "sys_role"
|
|
|
|
|
|
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
|
|
|
role_name: Mapped[str] = mapped_column(String(64))
|
|
|
|
|
role_code: Mapped[str] = mapped_column(String(64), unique=True, index=True)
|
|
|
|
|
status: Mapped[int] = mapped_column(Integer, default=1)
|
|
|
|
|
remark: Mapped[str | None] = mapped_column(String(255), nullable=True)
|
|
|
|
|
|
|
|
|
|
|
2026-05-15 09:00:50 +08:00
|
|
|
class RoleMenu(TimestampMixin, Base):
|
|
|
|
|
__tablename__ = "sys_role_menu"
|
|
|
|
|
|
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
|
|
|
role_id: Mapped[int] = mapped_column(Integer, index=True)
|
|
|
|
|
menu_id: Mapped[int] = mapped_column(Integer, index=True)
|
|
|
|
|
|
|
|
|
|
|
2026-05-14 13:51:06 +08:00
|
|
|
class Menu(TimestampMixin, Base):
|
|
|
|
|
__tablename__ = "sys_menu"
|
|
|
|
|
|
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
|
|
|
parent_id: Mapped[int] = mapped_column(Integer, default=0)
|
|
|
|
|
menu_name: Mapped[str] = mapped_column(String(64))
|
|
|
|
|
menu_path: Mapped[str] = mapped_column(String(128), default="")
|
|
|
|
|
menu_type: Mapped[str] = mapped_column(String(32), default="page")
|
|
|
|
|
permission_code: Mapped[str] = mapped_column(String(128), unique=True, index=True)
|
|
|
|
|
icon: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
|
|
|
|
sort_no: Mapped[int] = mapped_column(Integer, default=0)
|
|
|
|
|
status: Mapped[int] = mapped_column(Integer, default=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SystemConfig(TimestampMixin, Base):
|
|
|
|
|
__tablename__ = "system_config"
|
|
|
|
|
|
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
|
|
|
config_key: Mapped[str] = mapped_column(String(128), unique=True, index=True)
|
|
|
|
|
config_value: Mapped[str] = mapped_column(String(2000), default="")
|
|
|
|
|
config_name: Mapped[str] = mapped_column(String(128))
|
|
|
|
|
remark: Mapped[str | None] = mapped_column(String(255), nullable=True)
|
|
|
|
|
status: Mapped[int] = mapped_column(Integer, default=1)
|
2026-05-15 11:47:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class AuditLog(Base):
|
|
|
|
|
__tablename__ = "audit_log"
|
|
|
|
|
|
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
|
|
|
operator_id: Mapped[int | None] = mapped_column(Integer, nullable=True, index=True)
|
|
|
|
|
operator_name: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
|
|
|
|
operate_time: Mapped[DateTime] = mapped_column(DateTime, server_default=func.now(), index=True)
|
|
|
|
|
operate_type: Mapped[str] = mapped_column(String(64))
|
|
|
|
|
biz_type: Mapped[str] = mapped_column(String(64), index=True)
|
|
|
|
|
biz_id: Mapped[int] = mapped_column(Integer, index=True)
|
|
|
|
|
before_value: Mapped[str | None] = mapped_column(String(4000), nullable=True)
|
|
|
|
|
after_value: Mapped[str | None] = mapped_column(String(4000), nullable=True)
|
|
|
|
|
result: Mapped[str] = mapped_column(String(32), default="success")
|
|
|
|
|
remark: Mapped[str | None] = mapped_column(String(1000), nullable=True)
|