jiangqs
2023-06-01 c680521b6a4759b0c43068e57a6e5cd2b0a90236
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
41
42
43
44
45
46
47
48
49
50
51
52
package com.ruoyi.system.api.factory;
 
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.domain.poji.config.Activeness;
import com.ruoyi.system.api.domain.poji.config.SysClassification;
import com.ruoyi.system.api.service.RemoteConfigService;
import com.ruoyi.system.api.domain.poji.config.SysTag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
 
import java.util.List;
 
/**
 * 系统配置服务
 * 
 * @author jqs
 */
@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<SysTag> getSysTag(Long sysTagId) {
                return R.fail("获取标签失败:" + throwable.getMessage());
            }
 
            @Override
            public R<List<SysTag>> listSysTag(Integer tagType) {
                return R.fail("获取标签失败:" + throwable.getMessage());
            }
 
            @Override
            public R<List<Activeness>> listActiveness() {
                return R.fail("获取活跃度失败:" + throwable.getMessage());
            }
 
            @Override
            public R<SysClassification> getSysClassification(Long classId) {
                return R.fail("获取分类失败:" + throwable.getMessage());
            }
        };
    }
}