package com.cpop.core.listen;

import com.cpop.core.base.table.OperationLog;
import com.cpop.core.event.OperationLogEvent;
import com.cpop.core.service.OperationLogService;
import com.cpop.core.utils.SpringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author: DB
 * @date: 2022-08-12 10:25
 * @Description:  操作日志监听
 */
@Slf4j
@Component
public class OperationLogListen {

    @Async
    @Order
    @EventListener(OperationLogEvent.class)
    public void saveSysOperationLog(OperationLogEvent event) {
        OperationLog operationLog = (OperationLog) event.getSource();
        // 保存日志
        if (SpringUtils.getBean(OperationLogService.class).save(operationLog)) {
        }
    }
}
