""" 操作日志模型 """ from sqlalchemy import Column, BigInteger, Integer, String, DateTime, ForeignKey, Text, SmallInteger from sqlalchemy.orm import relationship from app.database import Base class OperationLog(Base): """操作日志表""" __tablename__ = "operation_logs" id = Column(BigInteger, primary_key=True, index=True, comment="主键ID") admin_id = Column(Integer, ForeignKey("admins.id"), index=True, comment="管理员ID") module = Column(String(50), index=True, comment="操作模块") action = Column(String(50), index=True, comment="操作动作") description = Column(String(500), comment="操作描述") old_data = Column(Text, comment="操作前数据(JSON)") new_data = Column(Text, comment="操作后数据(JSON)") ip_address = Column(String(50), comment="IP地址") is_deleted = Column(SmallInteger, default=0, index=True, comment="是否删除:0-否,1-是") created_at = Column(DateTime, index=True, comment="操作时间") # 关系 admin = relationship("Admin", back_populates="operation_logs")