package com.yuchen.saas.device.api.feign.deviceCenter;

import com.yuchen.saas.device.api.dto.deviceCenter.SyncDeviceDataDeleteReqDTO;
import com.yuchen.saas.device.api.dto.deviceCenter.SyncDeviceDataSubmitReqDTO;
import com.yuchen.saas.device.api.utils.SaasDeviceFeignFallbackUtils;
import feign.hystrix.FallbackFactory;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.stereotype.Component;

@Component
public class DeviceCenterFeignFallback implements FallbackFactory<DeviceCenterFeign> {

    @Override
    public DeviceCenterFeign create(Throwable throwable) {
        return new DeviceCenterFeign() {

            @Override
            public R syncSubmitDeviceData(SyncDeviceDataSubmitReqDTO reqDTO) {
                return SaasDeviceFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R syncDeleteDeviceData(SyncDeviceDataDeleteReqDTO reqDTO) {
                return SaasDeviceFeignFallbackUtils.printLogAndReturn(throwable);
            }
        };
    }
}
