package com.ruoyi.basic.api.factory;

import com.ruoyi.basic.api.RemoteBasicService;
import com.ruoyi.basic.api.domain.HwTenant;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description: 通用模块服务降级处理
 * @ClassName: RemoteTenantFallbackFactory
 * @Author : xins
 * @Date :2023-09-16  21:48
 * @Version :1.0
 */
@Component
public class RemoteBasicFallbackFactory implements FallbackFactory<RemoteBasicService> {
    @Override
    public RemoteBasicService create(Throwable throwable) {
        return new RemoteBasicService() {
            @Override
            public R<List<HwTenant>> getTenants() {
                return R.fail("获取租户信息失败:" + throwable.getMessage());
            }
        };
    }
}
