27 lines
1.2 KiB
Python
27 lines
1.2 KiB
Python
from sqlalchemy import String, Integer, Text, BigInteger
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
from sqlalchemy.sql.schema import ForeignKey
|
|
from .base import Base, MYSQL_TABLE_ARGS
|
|
from datetime import datetime
|
|
from sqlalchemy import func
|
|
|
|
|
|
class SysLog(Base):
|
|
__tablename__ = "sys_log"
|
|
__table_args__ = MYSQL_TABLE_ARGS
|
|
|
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
user_id: Mapped[int | None] = mapped_column(Integer, ForeignKey("sys_user.user_id"), nullable=True, index=True)
|
|
username: Mapped[str | None] = mapped_column(String(50))
|
|
operation_type: Mapped[str] = mapped_column(String(50), nullable=False)
|
|
resource_type: Mapped[str] = mapped_column(String(50), nullable=False)
|
|
resource_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True, index=True)
|
|
detail: Mapped[str | None] = mapped_column(Text)
|
|
ip_address: Mapped[str | None] = mapped_column(String(50))
|
|
user_agent: Mapped[str | None] = mapped_column(String(500))
|
|
status: Mapped[int] = mapped_column(Integer, default=1)
|
|
error_message: Mapped[str | None] = mapped_column(Text)
|
|
created_at: Mapped[datetime] = mapped_column(default=func.now(), index=True)
|
|
|
|
user = relationship("User")
|