package com.vctgo.system.api.factory;

import com.vctgo.common.core.domain.R;
import com.vctgo.system.api.RemoteDictService;
import com.vctgo.system.api.domain.SysDictData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 用户服务降级处理
 *
 * @author vctgo
 */
@Component
public class RemoteDictFallbackFactory implements FallbackFactory<RemoteDictService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteDictFallbackFactory.class);

    @Override
    public RemoteDictService create(Throwable throwable) {
        log.error("区域服务调用失败:{}", throwable.getMessage());
        return new RemoteDictService() {
            @Override
            public R<List<SysDictData>> dictType(String dictType) {
                return R.fail("获取根据字典类型获取字典列表失败:" + throwable.getMessage());
            }
        };
    }
}
