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.IotAepProduct;
import com.sptg.iot.api.feigns.IotAepProductFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author zwx
 * @create 2020/10/21 0:43
 */
@Slf4j
@Component
public class IotAepProductFeignFallbackFactory implements FallbackFactory<IotAepProductFeign> {
    @Override
    public IotAepProductFeign create(Throwable cause) {
        return new IotAepProductFeign() {

            @Override
            public ResultBean<List<IotAepProduct>> getList() {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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