package com.ics.system.log;

import com.ics.common.redis.util.RedisUtils;
import com.ics.system.log.aspect.OperLogAspect;
import com.ics.system.log.listen.LogListener;
import com.ics.system.service.ILoginInfoService;
import com.ics.system.service.IOperLogService;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * 日志配置
 *
 */
@EnableAsync
@Configuration
@AllArgsConstructor
@ConditionalOnWebApplication
public class LogAutoConfiguration {

    private final IOperLogService logService;
    private final ILoginInfoService sysLoginInforService;
    private final RedisUtils        redis;

    @Bean
    public LogListener sysOperLogListener() {
        return new LogListener(logService, sysLoginInforService, redis);
    }

    @Bean
    public OperLogAspect operLogAspect() {
        return new OperLogAspect();
    }
}