liusuyi
2026-05-18 0b8c8d8986a35c3e36db1503125e2dff79d6d10e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.ard.system.api.factory;
 
import com.ard.common.core.domain.R;
import com.ard.system.api.RemoteConfigService;
import com.ard.system.api.domain.SysConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
 
import java.util.List;
 
/**
 * 系统总配置降级处理
 *
 * @author ard
 */
@Component
public class RemoteConfigFallbackFactory implements FallbackFactory<RemoteConfigService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteConfigFallbackFactory.class);
 
    @Override
    public RemoteConfigService create(Throwable throwable)
    {
        log.error("系统总配置:{}", throwable.getMessage());
        return new RemoteConfigService()
        {
            @Override
            public R<List<SysConfig>> listRpc(SysConfig sysConfig, String source) {
                return R.fail("查询报警总配置列表:" + throwable.getMessage());
            }
 
            @Override
            public R<String> getConfigKey(String configKey) {
                return R.fail("查询配置失败:" + throwable.getMessage());
            }
        };
    }
}