|
|
@@ -5,6 +5,7 @@ import (
|
|
|
"git.sxidc.com/go-framework/baize/framework/gateway"
|
|
|
"git.sxidc.com/go-tools/utils/strutils"
|
|
|
"git.sxidc.com/service-supports/fserr"
|
|
|
+ "github.com/gin-gonic/gin"
|
|
|
"net/http"
|
|
|
"net/url"
|
|
|
"sync"
|
|
|
@@ -28,13 +29,15 @@ func RegisterService(serviceShortName string, baseUrl string) {
|
|
|
serviceBaseUrlMap.Store(serviceShortName, baseUrl)
|
|
|
}
|
|
|
|
|
|
-func BuildGateway(builder *gateway.Builder, opts ...Option) {
|
|
|
+func BuildGateway(gw *gateway.Gateway, opts ...Option) {
|
|
|
options := new(Options)
|
|
|
|
|
|
for _, opt := range opts {
|
|
|
opt(options)
|
|
|
}
|
|
|
|
|
|
+ builder := gw.NewBuilder(api.RouterPrefix, "")
|
|
|
+
|
|
|
builder.
|
|
|
Url(http.MethodPost, "/sql/execute").
|
|
|
Post(gateway.NewPostRequest("",
|
|
|
@@ -122,14 +125,14 @@ func BuildGateway(builder *gateway.Builder, opts ...Option) {
|
|
|
var serviceUrl string
|
|
|
|
|
|
if strutils.IsStringEmpty(options.serviceApiVersion) {
|
|
|
- innerServiceUrl, err := url.JoinPath(serviceBaseUrl.(string), serviceShortName, "/api", "/configuration/values")
|
|
|
+ innerServiceUrl, err := url.JoinPath(serviceBaseUrl.(string), serviceShortName, "/api", "/sql/execute/log")
|
|
|
if err != nil {
|
|
|
return "", err
|
|
|
}
|
|
|
|
|
|
serviceUrl = innerServiceUrl
|
|
|
} else {
|
|
|
- innerServiceUrl, err := url.JoinPath(serviceBaseUrl.(string), serviceShortName, "/api", options.serviceApiVersion, "/configuration/values")
|
|
|
+ innerServiceUrl, err := url.JoinPath(serviceBaseUrl.(string), serviceShortName, "/api", options.serviceApiVersion, "/sql/execute/log")
|
|
|
if err != nil {
|
|
|
return "", err
|
|
|
}
|
|
|
@@ -143,4 +146,19 @@ func BuildGateway(builder *gateway.Builder, opts ...Option) {
|
|
|
gateway.FormQueryParamsWithTenantIDAndUserIDFunc("", "executorId")),
|
|
|
), nil).
|
|
|
Build()
|
|
|
+
|
|
|
+ // 查询注册的服务
|
|
|
+ builder.
|
|
|
+ Url(http.MethodGet, "/sql/execute/registered/services").
|
|
|
+ Local(func(c *api.Context) {
|
|
|
+ serviceShortNames := make([]string, 0)
|
|
|
+ serviceBaseUrlMap.Range(func(key any, value any) bool {
|
|
|
+ serviceShortNames = append(serviceShortNames, key.(string))
|
|
|
+ return true
|
|
|
+ })
|
|
|
+
|
|
|
+ c.JSON(http.StatusOK, gin.H{
|
|
|
+ "services": serviceShortNames,
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|