package com.mosty.operation.log;

import com.google.common.collect.Sets;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.lang.NonNull;

import java.util.Collections;
import java.util.Set;

public class LogSaveStrategy implements ApplicationContextAware {

    @Value("${spring.application.name}")
    private String applicationName;

    /** ioc 容器 */
    private static ApplicationContext applicationContext;

    private static final Set<String> NATIVE_APP_NAME = Collections.unmodifiableSet(Sets.newHashSet("mosty", "mosty-base"));

//    private final FeignClient;


    private Boolean nativeInvoke() {
        return NATIVE_APP_NAME.contains(applicationName);
    }

    @Override
    public void setApplicationContext(@NonNull ApplicationContext applicationContext) throws BeansException {
        LogSaveStrategy.applicationContext = applicationContext;
    }

    protected void saveOperationLog() {
        if (nativeInvoke()) {

        }
//        remoteFeign();
    }

}
