package com.usky.fire.factory;

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


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

    @Override
    public RemoteFireService create(Throwable throwable)
    {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteFireService()
        {
            @Override
            public void addPatrolInspectionAbnormalData() {
                throw new FeignBadRequestException(500,"获取巡检漏检数据异常"+throwable.getMessage());
            }
        };
    }
}
