Pu Zhibing
8 天以前 7a4f9541331bef779a506b38a27ed5c3373c0bec
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
53
54
55
56
57
58
59
60
61
package com.ruoyi.other.api.factory;
 
import com.ruoyi.account.api.dto.GiveVipDto;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.other.api.domain.TVip;
import com.ruoyi.other.api.feignClient.VipClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
 
import java.util.List;
 
/**
 * 会员服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class VipFallbackFactory implements FallbackFactory<VipClient>
{
    private static final Logger log = LoggerFactory.getLogger(VipFallbackFactory.class);
 
    @Override
    public VipClient create(Throwable throwable) {
        log.error("会员调用失败:{}", throwable.getMessage());
        return new VipClient() {
 
            @Override
            public R<TVip> getVipInfoByType(Integer type) {
                return R.fail("获取最高抵扣、最低起步价,最高折扣的会员失败:" + throwable.getMessage());
 
            }
            @Override
            public R<TVip> getInfo(Integer type) {
                return R.fail("获取数据失败:" + throwable.getMessage());
            }
 
            @Override
            public R giveVip(GiveVipDto giveVipDto) {
                return R.fail("赠送会员:" + throwable.getMessage());
            }
 
            @Override
            public R<List<TVip>> getVipList() {
                return R.fail("查询会员集合失败:" + throwable.getMessage());
            }
 
            @Override
            public R<TVip> getInfo1(Integer id) {
                return R.fail("根据会员id 获取会员信息:" + throwable.getMessage());
            }
 
            @Override
            public R<List<TVip>> getAllVip() {
                return R.fail("获取数据失败:" + throwable.getMessage());
            }
        };
    }
}