无关风月
2024-08-19 5a22de857470ed18e993260e2cf3a38a1a43de7e
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
package com.ruoyi.account.api.factory;
 
import com.ruoyi.account.api.feignClient.AppUserAddressClient;
import com.ruoyi.account.api.model.TAppUserAddress;
import com.ruoyi.account.api.model.TAppUserIntegralChange;
import com.ruoyi.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
 
/**
 * @author zhibing.pu
 * @Date 2024/8/16 11:02
 */
@Component
public class AppUserAddressFallbackFactory implements FallbackFactory<AppUserAddressClient> {
    
    private static final Logger log = LoggerFactory.getLogger(AppUserAddressFallbackFactory.class);
    
    
    @Override
    public AppUserAddressClient create(Throwable throwable) {
        log.error("用户地址调用失败:{}", throwable.getMessage());
        return new AppUserAddressClient(){
            
            @Override
            public R<TAppUserAddress> getAppUserAddressById(Long id) {
                return R.fail("根据id获取用户地址信息失败:" + throwable.getMessage());
            }
        };
    }
}