package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.system.api.RemoteRevenueConfigService;
import com.ruoyi.system.api.domain.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 用户服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteRevenueConfigFallbackFactory implements FallbackFactory<RemoteRevenueConfigService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteRevenueConfigFallbackFactory.class);

    @Override
    public RemoteRevenueConfigService create(Throwable throwable)
    {
        log.error("流量业务服务调用失败:{}", throwable.getMessage());
        return new RemoteRevenueConfigService()
        {

            @Override
            public R<String> autoSaveServiceTrafficData(EpsInitialTrafficDataRemote queryParam, String source) {
                return R.fail("保存流量数据失败:" + throwable.getMessage());
            }
            @Override
            public R<String> autoSaveSwitchTraffic(InitialSwitchInfoDetailsRemote queryParam, String source) {
                return R.fail("保存交换机流量数据失败:" + throwable.getMessage());
            }

            @Override
            public R<String> updateStatusByResource(RmResourceRegistrationRemote queryParam, String source) {
                return R.fail("资源状态修改失败:" + throwable.getMessage());
            }

            @Override
            public R<AllInterfaceNameRemote> getMsgByClientId(AllInterfaceNameRemote queryParam, String source) {
                return R.fail("获取服务器信息失败：" + throwable.getMessage());
            }

            @Override
            public R<RmResourceGroupRemote> getResourceGroupMsgById(Long id, String source) {
                return R.fail("获取资源组信息失败：" + throwable.getMessage());
            }

            @Override
            public R<List<RmResourceRegistrationRemote>> getRegistrationByIds(String[] ids, String source) {
                return R.fail("获取资源注册信息失败：" + throwable.getMessage());
            }

            @Override
            public R<TableDataInfo> getRegistrationList(RmResourceRegistrationRemote rmResourceRegistrationRemote, String source) {
                return R.fail("获取资源注册列表信息失败：" + throwable.getMessage());
            }

            @Override
            public R<RmResourceRegistrationRemote> getListByHardwareSn(RmResourceRegistrationRemote rmResourceRegistrationRemote, String source) {
                return R.fail("根据SN获取资源注册列表信息失败：" + throwable.getMessage());
            }

            @Override
            public R<List<RmSwitchManagementRemote>> getSwitchNameByClientId(RmSwitchManagementRemote rmSwitchManagementRemote, String source) {
                return R.fail("根据clientId获取交换机信息失败：" + throwable.getMessage());
            }

            @Override
            public R<Integer> updateSwitchMsgByClientId(RmSwitchManagementRemote rmSwitchManagementRemote, String source) {
                return R.fail("根据clientId修改交换机信息失败：" + throwable.getMessage());
            }

            @Override
            public R<Integer> innerAddRegist(RmRegisterMsgRemote rmRegisterMsgRemote, String source) {
                return R.fail("自动注册失败：" + throwable.getMessage());
            }

            @Override
            public R<Integer> innerUpdateRegist(RmResourceRegistrationRemote rmResourceRegistrationRemote, String source) {
                return R.fail("修改服务器注册信息失败：" + throwable.getMessage());
            }

            @Override
            public R<List<EpsNodeBandwidthRemote>> getEpsNodeBandWidthList(EpsNodeBandwidthRemote epsNodeBandwidthRemote, String source) {
                return R.fail("获取95值列表失败：" + throwable.getMessage());
            }
        };
    }
}
