|
|
|
@ -0,0 +1,32 @@
|
|
|
|
|
package com.sztzjy.forex.trading_trading.config;
|
|
|
|
|
|
|
|
|
|
import com.sztzjy.forex.trading_trading.entity.Log;
|
|
|
|
|
import com.sztzjy.forex.trading_trading.service.LogService;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.context.event.EventListener;
|
|
|
|
|
import org.springframework.core.annotation.Order;
|
|
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 事件监听器
|
|
|
|
|
*/
|
|
|
|
|
@Component
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class SpringContextEventListener {
|
|
|
|
|
private final LogService logService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 异步保存操作日志
|
|
|
|
|
*
|
|
|
|
|
* @param event 发布日志事件 详见{@link com.sztzjy.forex.trading_trading.annotation.aspect.OperateLogAspect},{@link LogRecordEvent}
|
|
|
|
|
*/
|
|
|
|
|
@Order
|
|
|
|
|
@Async
|
|
|
|
|
@EventListener(LogRecordEvent.class)
|
|
|
|
|
public void logListener(LogRecordEvent event) {
|
|
|
|
|
Log log = (Log) event.getSource();
|
|
|
|
|
logService.add(log);
|
|
|
|
|
}
|
|
|
|
|
}
|