from datetime import datetime
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey

from app.core.database import Base


class OperationLog(Base):
    __tablename__ = "sys_operation_log"

    id = Column(Integer, primary_key=True, index=True)
    user_id = Column(Integer, ForeignKey("sys_user.id"), nullable=True)
    username = Column(String(50))
    module = Column(String(50))
    action = Column(String(50))
    method = Column(String(10))
    path = Column(String(500))
    ip = Column(String(50))
    request_body = Column(Text)
    response_body = Column(Text)
    status_code = Column(Integer)
    duration_ms = Column(Integer)
    created_at = Column(DateTime, default=datetime.utcnow)
