Files
aiagent/backend/app/models/audit_log.py
renjianbo beff3fac8d fix: delete agent 500 error + dynamic personality + deployment guide
- Fix delete agent 500: clean up FK records (agent_llm_logs, permissions,
  schedules, executions, team_members) and unbind goals/tasks before delete
- Remove hardcoded personality templates in Android, replace with dynamic
  system prompt generation from name + description
- Set promptSectionsEnabled=false to bypass PromptComposer for personality
- Add Tencent Cloud Linux deployment guide (Docker Compose)
- Accumulated backend service updates, frontend UI fixes, Android app changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-29 01:17:21 +08:00

27 lines
1.3 KiB
Python

"""
操作审计日志模型
"""
import uuid
from sqlalchemy import Column, String, Text, DateTime, JSON, func
from sqlalchemy.dialects.mysql import CHAR
from app.core.database import Base
class AuditLog(Base):
__tablename__ = "audit_logs"
id = Column(CHAR(36), primary_key=True, default=lambda: str(uuid.uuid4()), comment="日志ID")
user_id = Column(CHAR(36), nullable=False, index=True, comment="操作用户ID")
username = Column(String(100), nullable=False, comment="操作用户名")
action = Column(String(50), nullable=False, index=True, comment="操作类型: CREATE/UPDATE/DELETE/EXECUTE/LOGIN")
resource_type = Column(String(100), nullable=False, comment="资源类型: agent/workflow/user/permission/...")
resource_id = Column(String(100), nullable=True, comment="资源ID")
resource_name = Column(String(255), nullable=True, comment="资源名称")
detail = Column(JSON, nullable=True, comment="操作详情")
ip_address = Column(String(45), nullable=True, comment="客户端IP")
status = Column(String(20), nullable=False, default="success", comment="操作状态: success/failure")
created_at = Column(DateTime, default=func.now(), index=True, comment="操作时间")
def __repr__(self):
return f"<AuditLog(id={self.id}, user={self.username}, action={self.action}, resource={self.resource_type})>"