liujie
2026-06-09 c96fbe6b0aeb413a17c429133ee6d81d138144b9
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
package com.xiaopeng.api.factory.maintenance;
 
import com.xiaopeng.api.feignClient.maintenance.XpCheckLocationClient;
import com.xiaopeng.api.model.maintenance.XpCheckLocation;
import com.xiaopeng.common.core.domain.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
 
import java.util.List;
 
/**
 * 打卡地址Feign客户端降级工厂
 *
 * @author mitao
 * @since 2026-02-13
 */
@Slf4j
@Component
public class XpCheckLocationClientFallbackFactory implements FallbackFactory<XpCheckLocationClient> {
 
    @Override
    public XpCheckLocationClient create(Throwable cause) {
        log.error("打卡地址服务调用失败: {}", cause.getMessage());
        return new XpCheckLocationClient() {
            @Override
            public R<XpCheckLocation> queryById(Long id) {
                log.error("远程调用获取检查点位信息异常:{}", cause.getMessage());
                return R.fail("远程调用获取检查点位信息异常");
            }
 
            @Override
            public R<List<XpCheckLocation>> listByIds(List<Long> ids) {
                log.error("远程调用批量获取检查点位信息异常:{}", cause.getMessage());
                return R.fail("远程调用批量获取检查点位信息异常");
            }
        };
    }
}