package com.sptg.iot.api.feigns.fallback;

import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.iot.api.entity.IotSubscribe;
import com.sptg.iot.api.feigns.IotSubscribeFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author zwx
 * @create 2020/11/5 14:31
 */
@Component
@Slf4j
public class IotSubscribeFeignFallbackFactory implements FallbackFactory<IotSubscribeFeign> {
    @Override
    public IotSubscribeFeign create(Throwable cause) {
        return new IotSubscribeFeign() {
            @Override
            public ResultBean<String> subscribe(IotSubscribe iotSubscribe) {
               log.error(cause.getMessage(), cause);
               return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> inquire(IotSubscribe iotSubscribe) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
