package com.vctgo.system.api.factory;

import com.vctgo.common.core.domain.R;
import com.vctgo.system.api.RemoteLocationService;
import com.vctgo.system.api.domain.SysLocationSetting;
import com.vctgo.system.api.domain.SysReLocationClass;
import com.vctgo.system.api.domain.dto.SysLocationDto;
import com.vctgo.system.api.domain.dto.SysLocationReClassDto;
import com.vctgo.system.api.domain.dto.TemporaryConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

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

    @Override
    public RemoteLocationService create(Throwable throwable) {
        return new RemoteLocationService() {
            @Override
            public R<List<SysLocationSetting>> allList(TemporaryConfig temporaryConfig) {
                return R.fail("获取全量位置信息失败:" + throwable.getMessage());
            }

            @Override
            public R<List<SysLocationSetting>> locationIdList(SysLocationSetting sysLocationSetting) {
                return R.fail("获取位置id信息失败:" + throwable.getMessage());
            }

            @Override
            public R<List<SysLocationReClassDto>> getRelatedClassList(SysLocationReClassDto sysLocationReClassDto) {
                return R.fail("根据位置信息查询其对应的班级信息失败:" + throwable.getMessage());
            }

            @Override
            public R<List<SysLocationSetting>> locationIdList(Long[] locationIdArray) {
                return R.fail("根据位置信息查询其对应的班级信息失败:" + throwable.getMessage());
            }

            @Override
            public R<List<SysLocationSetting>> locationAndAreaList(String tenantId) {
                return R.fail("根据位置信息查询其对应的班级信息失败:" + throwable.getMessage());
            }

            @Override
            public R<List<SysLocationReClassDto>> getRelatedLocationList(SysLocationReClassDto sysLocationReClassDto) {
                return R.fail("根据位置信息查询其对应的班级信息失败:" + throwable.getMessage());
            }

            @Override
            public R<List<SysLocationDto>> getLocationIdList(SysLocationDto locationDto) {
                return R.fail("获取位置id信息失败:" + throwable.getMessage());
            }

            @Override
            public R<List<SysLocationSetting>> getLocationSettingInfo(String attribute) {
                return R.fail("获取位置id信息失败:" + throwable.getMessage());
            }

            @Override
            public R<List<SysReLocationClass>> getLocationSettingInfoByClassId(String classId) {
                return R.fail("获取位置id信息失败:" + throwable.getMessage());
            }

            @Override
            public R<List<SysReLocationClass>> getLocationSettingInfoByClassIds(String classIds) {
                return R.fail("获取位置id信息失败:" + throwable.getMessage());
            }
        };
    }
}
