package com.usky.system.factory;


import com.usky.common.core.exception.FeignBadRequestException;
import com.usky.system.RemoteDictService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 消息服务降级处理
 * 
 * @author ruoyi
 */
@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 String selectNameById(String dictType,String dictValue)
            {
                throw new FeignBadRequestException(500,"查询字典异常"+throwable.getMessage());
            }
        };
    }
}
