up
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"""管理后台域:admin_users / admin_logs"""
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import DateTime, Index, SmallInteger, String, func
|
||||
from sqlalchemy.dialects.mysql import BIGINT
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.models.base import Base
|
||||
|
||||
|
||||
class AdminUser(Base):
|
||||
__tablename__ = "admin_users"
|
||||
|
||||
id: Mapped[int] = mapped_column(BIGINT(unsigned=True), primary_key=True, autoincrement=True)
|
||||
username: Mapped[str] = mapped_column(String(50), unique=True)
|
||||
password_hash: Mapped[str] = mapped_column(String(255))
|
||||
name: Mapped[str] = mapped_column(String(50), default="")
|
||||
role: Mapped[str] = mapped_column(String(20), comment="super/reviewer/operator")
|
||||
status: Mapped[int] = mapped_column(SmallInteger, default=1, comment="1正常 0禁用")
|
||||
last_login_at: Mapped[datetime | None] = mapped_column(DateTime)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
|
||||
|
||||
|
||||
class AdminLog(Base):
|
||||
__tablename__ = "admin_logs"
|
||||
|
||||
id: Mapped[int] = mapped_column(BIGINT(unsigned=True), primary_key=True, autoincrement=True)
|
||||
admin_id: Mapped[int] = mapped_column(BIGINT(unsigned=True))
|
||||
action: Mapped[str] = mapped_column(String(50))
|
||||
target: Mapped[str] = mapped_column(String(100), default="")
|
||||
detail: Mapped[str] = mapped_column(String(1000), default="")
|
||||
ip: Mapped[str] = mapped_column(String(45), default="")
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
|
||||
|
||||
__table_args__ = (Index("idx_admin_created", "admin_id", "created_at"),)
|
||||
Reference in New Issue
Block a user