无关风月
2025-03-16 91df8c9b3dac121493b03c9ce1890953c1879603
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.ruoyi.chargingPile.api.factory;
 
import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient;
import com.ruoyi.chargingPile.api.feignClient.ParkingLotClient;
import com.ruoyi.chargingPile.api.model.TChargingPile;
import com.ruoyi.chargingPile.api.model.TParkingLot;
import com.ruoyi.chargingPile.api.model.TParkingRecord;
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;
 
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
 
/**
 * 停车场服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class ParkingLotFallbackFactory implements FallbackFactory<ParkingLotClient>
{
    private static final Logger log = LoggerFactory.getLogger(ParkingLotFallbackFactory.class);
 
    @Override
    public ParkingLotClient create(Throwable throwable) {
        log.error("停车场调用失败:{}", throwable.getMessage());
        return new ParkingLotClient() {
 
            @Override
            public R<TParkingLot> getLotBySiteId(Integer siteId) {
                return R.fail("通过站点id查询停车场信息调用失败:" + throwable.getMessage());
            }
    
    
            @Override
            public R<List<TParkingLot>> getAllParkingLot() {
                return R.fail("获取所有停车场数据失败:" + throwable.getMessage());
            }
    
            @Override
            public R<TParkingRecord> getRecordById(Long siteId) {
                return R.fail("通过id查询停车场记录:" + throwable.getMessage());
            }
 
            @Override
            public R<BigDecimal> getRecordAmount(String sixBefore) {
                return null;
            }
    
            @Override
            public R<TParkingLot> getParkingLotByAppKey(String appKey) {
                return R.fail("根据停车场标识查询失败:" + throwable.getMessage());
            }
 
            @Override
            public R<Integer> getSiteIdByOrderId(Long id) {
                return null;
            }
 
            @Override
            public R<List<TParkingRecord>> getSiteIdAll() {
                return null;
            }
        };
    }
}