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
package com.xiaopeng.api.factory.maintenance;
 
import com.xiaopeng.api.feignClient.maintenance.XpClockInClient;
import com.xiaopeng.common.core.domain.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
 
/**
 * 打卡服务降级工厂
 *
 * @author mitao
 * @date 2026-02-14
 */
@Slf4j
@Component
public class XpClockInClientFallbackFactory implements FallbackFactory<XpClockInClient> {
 
    @Override
    public XpClockInClient create(Throwable cause) {
        return new XpClockInClient() {
            @Override
            public R<Integer> checkWorkStatus(Long appUserId) {
                log.error("调用打卡服务检查上班状态失败, appUserId={}, 异常: {}",
                    appUserId, cause.getMessage(), cause);
                // 降级策略: 返回  (未上班状态)
                return R.ok(1);
            }
        };
    }
}