package com.usky.vpp.factory;

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

@Component
public class RemoteVppTaskFactory implements FallbackFactory<RemoteVppTaskService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteVppTaskFactory.class);

    @Override
    public RemoteVppTaskService create(Throwable throwable) {
        log.error("VPP 定时任务服务调用失败: {}", throwable.getMessage());
        return () -> {
            throw new FeignBadRequestException(500, "定时刷新站点平均完成率异常" + throwable.getMessage());
        };
    }
}
