package com.xunmei.system.api.factory;

import com.xunmei.system.api.RemoteDeviceService;
import com.xunmei.system.api.domain.SysDevice;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author :LuoWei
 * @date : 2023/8/29
 */
@Component
public class RemoteDeviceFallbackFactory implements FallbackFactory<RemoteDeviceService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteDeviceFallbackFactory.class);

    @Override
    public RemoteDeviceService create(Throwable cause) {
        log.error("用户服务调用失败:{}", cause.getMessage());
        return new RemoteDeviceService() {
            @Override
            public List<SysDevice> getSysDeviceByOrgId(Long orgId, String source) {
                return null;
            }

            @Override
            public List<SysDevice> getSysDeviceByHostId(Long hostId, String source) {
                return null;
            }
        };
    }
}
