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

/**
 * @author zwx
 * @create 2020/10/27 16:42
 */
@Component
@Slf4j
public class IotAuthFeignFallbackFactory implements FallbackFactory<IotAuthFeign> {

    @Override
    public IotAuthFeign create(Throwable cause) {
        return new IotAuthFeign() {
            @Override
            public ResultBean<IotAuthentication> auth(String appId) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
