package com.sptg.third.api.feigns.grid.fallback;

import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.third.api.feigns.grid.GridAuthFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author zwx
 * @create 2020/11/28 20:19
 */
@Slf4j
@Component
public class GridAuthFeignFallbackFactory implements FallbackFactory<GridAuthFeign> {
    @Override
    public GridAuthFeign create(Throwable cause) {
        return new GridAuthFeign() {
            @Override
            public ResultBean<String> gridAuth() {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
