package com.jeeplus.sys.factory;

import com.jeeplus.sys.feign.ITenantApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 租户服务降级处理
 *
 * @author jeeplus
 */

@Slf4j
@Component
public class TenantApiFallbackFactory implements FallbackFactory <ITenantApi> {
    @Override
    public ITenantApi create(Throwable throwable) {
        log.error ( "租户服务调用失败:{}", throwable.getMessage ( ) );
        throwable.printStackTrace ( );
        return new ITenantApi ( ) {

            @Override
            public String getCurrentTenantId() {
                return null;
            }
        };
    }
}
