Pu Zhibing
2025-03-26 7f26677ab7f9b83697370fa142dd1686cdf4082a
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
package com.ruoyi.other.api.factory;
 
import com.ruoyi.common.core.domain.R;
import com.ruoyi.other.api.domain.Goods;
import com.ruoyi.other.api.feignClient.GoodsClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
 
import java.util.List;
 
/**
 * @author zhibing.pu
 * @Date 2024/11/27 19:57
 */
@Slf4j
public class GoodsClientFallbackFactory implements FallbackFactory<GoodsClient> {
    
    
    @Override
    public GoodsClient create(Throwable cause) {
        return new GoodsClient(){
            
            @Override
            public R<List<Goods>> getGoodsByType(Integer type) {
                return R.fail("根据类型(1=服务商品,2=单品商品)获取商品数据失败:" + cause.getMessage());
            }
            
            @Override
            public R<Goods> getGoodsById(Integer id) {
                return R.fail("根据id获取商品详情失败:" + cause.getMessage());
            }
 
            @Override
            public R<List<Goods>> getGoodsById(String [] ids) {
                return R.fail("根据ids获取商品详情失败:" + cause.getMessage());
            }
 
            @Override
            public R editGoodsList(List<Goods> goods) {
                return R.fail("编辑商品信息失败:" + cause.getMessage());
            }
 
            @Override
            public R<Void> editGoodsNum(Integer goodsId, Integer num) {
                return R.fail();
            }
 
            @Override
            public R<List<Goods>> getAllGoods() {
                return R.fail("获取所有商品失败:" + cause.getMessage());
            }
        };
    }
}