xuhy
2024-09-06 f2dff53d76a7e9a23e6a2ecfed58ce978dc41442
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
package com.ruoyi.chargingPile.api.factory;
 
import com.ruoyi.chargingPile.api.feignClient.AccountingStrategyClient;
import com.ruoyi.chargingPile.api.model.TAccountingStrategy;
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/28 18:33
 */
@Component
public class AccountingStrategyFallbackFactory implements FallbackFactory<AccountingStrategyClient> {
    private static final Logger log = LoggerFactory.getLogger(AccountingStrategyFallbackFactory.class);
    
    
    @Override
    public AccountingStrategyClient create(Throwable throwable) {
        log.error("计费策略调用失败:{}", throwable.getMessage());
        return new AccountingStrategyClient(){
            
            
            @Override
            public R<TAccountingStrategy> getAccountingStrategyById(Integer id) {
                throw new RuntimeException("根据id查询计费策略失败:" + throwable.getMessage());
            }
        };
    }
}