package com.usky.fire.factory;

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


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

    @Override
    public RemotePlanSonService create(Throwable throwable)
    {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemotePlanSonService()
        {
            @Override
            public void addPlanSon() {
                throw new FeignBadRequestException(500,"生成子计划数据异常"+throwable.getMessage());
            }
        };
    }
}
