Pu Zhibing
2024-11-29 2ccdf86ac2599562ca994bc4047ded2d925e8bae
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
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());
            }
        };
    }
}