package com.qqchen.deploy.backend.framework.audit.listener;

import com.qqchen.deploy.backend.framework.audit.event.AuditEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class AuditEventListener {

    @Async
    @EventListener
    public void handleAuditEvent(AuditEvent event) {
        // 这里可以将审计信息保存到数据库或发送到日志系统
        log.info("Audit: {} performed {} on {} (ID: {}) at {}, detail: {}",
            event.getMetadata().getOperator(),
            event.getMetadata().getAction(),
            event.getMetadata().getEntityType(),
            event.getMetadata().getEntityId(),
            event.getMetadata().getTimestamp(),
            event.getMetadata().getDetail()
        );
    }
} 