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

import com.yuchen.saas.device.api.utils.SaasDeviceFeignFallbackUtils;
import com.yuchen.saas.device.api.vo.RunDeviceSceneLinkageRuleVo;
import feign.hystrix.FallbackFactory;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.stereotype.Component;

@Component
public class DeviceSceneLinkageRuleClientFallback implements FallbackFactory<DeviceSceneLinkageRuleClient> {

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

            @Override
            public R propertyRunRule(RunDeviceSceneLinkageRuleVo ruleVo) {
                return SaasDeviceFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R eventRunRule(RunDeviceSceneLinkageRuleVo ruleVo) {
                return SaasDeviceFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R deviceStatusChangeRunRule(RunDeviceSceneLinkageRuleVo ruleVo) {
                return SaasDeviceFeignFallbackUtils.printLogAndReturn(throwable);
            }
        };
    }


}
