package com.jeeplus.sys.factory;

import com.jeeplus.sys.feign.IDictApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 字典服务降级处理
 *
 * @author jeeplus
 */

@Slf4j
@Component
public class DictApiFallbackFactory implements FallbackFactory <IDictApi> {
    @Override
    public IDictApi create(Throwable throwable) {
        log.error ( "字典服务调用失败:{}", throwable.getMessage ( ) );
        throwable.printStackTrace ( );
        return new IDictApi ( ) {
            @Override
            public String getDictValue(String label, String type, String defaultValue) {
                return null;
            }

            @Override
            public String getDictLabel(String value, String type, String defaultLabel) {
                return null;
            }

            @Override
            public String getDictMap(String dict) {
                return null;
            }
        };
    }
}
