from sqlalchemy import Integer, String 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) 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)