package com.yuchen.saas.park.api.feign.service;

import com.yuchen.saas.park.api.response.ParkInfoResponse;
import feign.hystrix.FallbackFactory;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: 肖润飞
 * @CreateTime: 2022/11/15 16:19
 * @Description: TODO
 * @Version: 1.0
 */
@Component
public class ParkDeviceCategoryFeignServiceFallback implements FallbackFactory<ParkDeviceCategoryFeignService> {

    @Override
    public ParkDeviceCategoryFeignService create(Throwable cause) {

        return new ParkDeviceCategoryFeignService() {
            @Override
            public R clearCache() {
                if (cause != null) {
                    String message = cause.getMessage();
                    return R.error(message);
                }
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R parkDeviceDataCount(Long parkId) {
                if (cause != null) {
                    String message = cause.getMessage();
                    return R.error(message);
                }
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R parkDeviceDataCategory(String scopeValue) {
                if (cause != null) {
                    String message = cause.getMessage();
                    return R.error(message);
                }
                return R.error("调用接口错误，熔断机制！");
            }
        };
    }
}