package com.microservices.system.api.factory;

import com.alibaba.fastjson2.JSONObject;
import com.microservices.common.core.exception.ServiceException;
import com.microservices.system.api.RemoteGatewayService;
import com.microservices.system.api.model.GraphqlQueryVo;
import feign.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

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

    @Override
    public RemoteGatewayService create(Throwable throwable) {
        log.error("网关服务调用失败:{}", throwable.getMessage());
        return new RemoteGatewayService() {

            @Override
            public Response loginSentinel(String username, String password) {
                return null;
            }

            @Override
            public Response loginRancher(JSONObject loginBody) {
                return null;
            }

            @Override
            public Response loginNacos(Map<String, ?> formParams) {
                return null;
            }

            @Override
            public Response loginPortainer(JSONObject loginBody) {
                return null;
            }

            @Override
            public JSONObject getPrometheusQueryRes(String query, String token) {
                return null;
            }

            @Override
            public JSONObject getPrometheusQueryRangeRes(String query, Long step, Long start, Long end, String token) {
                return null;
            }

            @Override
            public JSONObject executeSkywalkingGql(GraphqlQueryVo gqlBody) {
                return null;
            }

            @Override
            public JSONObject getSentinelAppList(String token) {
                return null;
            }

            @Override
            public JSONObject getNacosServiceList(String serviceNameParam, String token) {
                return null;
            }

            @Override
            public JSONObject getGatewayNacosConfigList(String dataId, String token) {
                return null;
            }

            @Override
            public JSONObject getNacosConfigList(String ip, String token) {
                return null;
            }

            @Override
            public String getNacosConfigDetail(String dataId, String group, String token) {
                return null;
            }

            @Override
            public Response updateNacosConfig(Map<String, ?> formParams, String userKey) {
                return null;
            }

            @Override
            public JSONObject executeElasticsearchQuery(String esIndex, JSONObject esBody) {
                return null;
            }

            @Override
            public JSONObject executeElasticsearchUpdate(String esIndex, String docId, JSONObject esBody) {
                return null;
            }

            @Override
            public JSONObject sendNotification(JSONObject body) {
                return null;
            }
        };
    }
}
