package com.securitycontrol.system.api.factory;


import com.securitycontrol.common.core.domain.Result;
import com.securitycontrol.system.api.RemoteProteamService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author HeiZi
 */
@Slf4j
@Component
public class RemoteProteamFallbackFactory implements FallbackFactory<RemoteProteamService> {

    @Override
    public RemoteProteamService create(Throwable throwable) {

        log.error("工程班组服务调用失败:{}", throwable.getMessage());
        return new RemoteProteamService() {
            @Override
            public Result<Object> asyncDeviceList(String source) {
                return Result.fail("同步第三方设备数据失败:" + throwable.getMessage());
            }

            @Override
            public Result<Object> catchPicture(String source) {
                return Result.fail("单次抓图调用失败:" + throwable.getMessage());
            }

            @Override
            public Result<Object> downloadPic(String source) {
                return Result.fail("下载图片转交人工智能平台调用失败:" + throwable.getMessage());
            }
        };

    }
}
