liusuyi
2026-05-12 9f327c33730ba10cb2d89aff99b727502232e968
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
package com.ard.work.api.factory;
 
import com.ard.common.core.domain.R;
import com.ard.common.core.web.domain.AjaxResult;
import com.ard.work.api.RemoteCameraService;
import com.ard.work.api.RemoteChannelService;
import com.ard.work.api.domian.ArdCamera;
import com.ard.work.api.domian.ArdChannel;
import com.ard.work.api.domian.CameraCmd;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
 
import java.util.List;
import java.util.TreeMap;
 
/**
 * 通道服务降级处理
 * 
 * @author ard
 */
@Component
public class RemoteChannelFallbackFactory implements FallbackFactory<RemoteChannelService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteChannelFallbackFactory.class);
 
    @Override
    public RemoteChannelService create(Throwable throwable)
    {
        log.error("相机服务调用失败:{}", throwable.getMessage());
        return new RemoteChannelService()
        {
 
            @Override
            public R<List<ArdChannel>> list(ArdChannel ardChannel, String source) {
                return R.fail("获取通道列表失败:" + throwable.getMessage());
            }
 
            @Override
            public R<ArdChannel>  getInfo(String id, String source) {
                return R.fail("获取通道信息失败:" + throwable.getMessage());
            }
 
            @Override
            public R<List<ArdChannel>> queryByIds(List<String> startChannelIdList, String inner) {
                return R.fail("获取通道列表失败:" + throwable.getMessage());
            }
 
            @Override
            public R<Boolean> update(ArdChannel ardChannel, String source) {
                return R.fail("更新通道失败:" + throwable.getMessage());
            }
        };
    }
}