package com.microservices.system.api;

import com.alibaba.fastjson2.JSONObject;
import com.microservices.common.core.constant.ServiceNameConstants;
import com.microservices.system.api.factory.RemoteGatewayFallbackFactory;
import feign.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * 网关
 *
 * @author microservices
 */
@Component
@FeignClient(contextId = "remoteGatewayService", value = ServiceNameConstants.GATEWAY_SERVICE, fallbackFactory = RemoteGatewayFallbackFactory.class)
public interface RemoteGatewayService {
    /**
     * 登录Sentinel
     *
     * @return 响应
     */
    @PostMapping("/sentinel/auth/login")
    Response loginSentinel(@RequestParam("username") String username, @RequestParam("password") String password);

    /**
     * 登录Nacos
     *
     * @return 响应
     */
    @PostMapping(value = "/nacos/v1/auth/users/login", consumes = {"application/x-www-form-urlencoded"})
    Response loginNacos(Map<String, ?> formParams);

    /**
     * 登录Portainer
     *
     * @return 响应
     */
    @PostMapping("/portainer/api/auth")
    Response loginPortainer(@RequestBody JSONObject loginBody);
}
