Files
FastapiAdmin/backend/app/api/v1/models/system/operation_log_model.py
T
zhangtao e7ebbf5479 feat: 优化前端组件样式及功能
refactor: 重构定时任务表单布局
fix: 修复用户导入组件按钮顺序
style: 统一对话框按钮顺序
feat: 添加用户头像默认显示
refactor: 移除表格列筛选功能
feat: 添加vue3-cron-plus-picker类型定义
fix: 修正日志处理时间显示格式
style: 优化IntervalTab组件布局
2025-07-26 11:51:04 +08:00

46 lines
2.0 KiB
Python

# -*- coding: utf-8 -*-
from datetime import datetime
from sqlalchemy import Column, ForeignKey, String, Integer, Text, DateTime, Float
from sqlalchemy.orm import relationship
from app.core.base_model import ModelBase
class OperationLogModel(ModelBase):
""" 操作日志模型,用于记录系统的操作日志 """
__tablename__ = "system_operation_log"
__table_args__ = ({'comment': '操作日志表'})
id = Column(Integer, primary_key=True, autoincrement=True, comment='主键ID')
type = Column(Integer, nullable=True, comment="日志类型(1登录日志 2操作日志)", index=True)
request_path = Column(String(255), nullable=True, comment="请求路径", index=True)
request_method = Column(String(10), nullable=True, comment="请求方式", index=True)
request_payload = Column(Text, nullable=True, comment="请求体")
request_ip = Column(String(50), nullable=True, comment="请求IP地址")
login_location=Column(String(255), nullable=True, comment="登录位置")
request_os = Column(String(64), nullable=True, comment="操作系统")
request_browser = Column(String(64), nullable=True, comment="浏览器")
response_code = Column(Integer, nullable=True, comment="响应状态码")
response_json = Column(Text, nullable=True, comment="响应体")
process_time = Column(String(20), nullable=True, comment="处理时间")
# 审计字段
description = Column(Text, nullable=True, comment="备注说明")
created_at = Column(DateTime, default=datetime.now, comment='创建时间')
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
creator_id = Column(
Integer,
ForeignKey("system_users.id", ondelete="SET NULL", onupdate="CASCADE"),
nullable=True,
index=True,
comment="创建人ID"
)
creator = relationship(
"UserModel",
foreign_keys=creator_id,
lazy="joined",
post_update=True,
uselist=False
)