package com.usky.eg.factory;

import com.usky.common.core.exception.FeignBadRequestException;
import com.usky.eg.RemoteEgService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;


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

    @Override
    public RemoteEgService create(Throwable throwable)
    {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteEgService() {
            @Override
            public void egDeviceStatus() {
                throw new FeignBadRequestException(500,"同步门禁设备状态异常"+throwable.getMessage());
            }
        };
    }
}
