jiangqs
2023-05-03 3bba8ccaea4c0ff7ad5a7acb056d554c42b2eca2
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.system.api.factory;
 
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteMemberService;
import com.ruoyi.system.api.RemoteShopService;
import com.ruoyi.system.api.domain.poji.shop.Shop;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
 
/**
 * 商户服务
 * 
 * @author jqs
 */
@Component
public class RemoteShopFallbackFactory implements FallbackFactory<RemoteShopService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteShopFallbackFactory.class);
 
    @Override
    public RemoteShopService create(Throwable throwable)
    {
        log.error("商户服务调用失败:{}", throwable.getMessage());
        return new RemoteShopService()
        {
            @Override
            public R<Shop> getShop(Long shopId) {
                return R.fail("获取商户失败:" + throwable.getMessage());
            }
        };
    }
}