yjp před 1 rokem
rodič
revize
99876982a5
3 změnil soubory, kde provedl 27 přidání a 4 odebrání
  1. 7 1
      client/data_container.go
  2. 7 1
      client/data_source.go
  3. 13 2
      client/sql.go

+ 7 - 1
client/data_container.go

@@ -1,6 +1,7 @@
 package client
 
 import (
+	"encoding/json"
 	"fmt"
 	"git.sxidc.com/go-tools/api_binding/http_binding/response"
 	"net/url"
@@ -20,11 +21,16 @@ func (c *Client) CreateDataContainer(token string, baseUrl string, namespace str
 
 	resp := new(response.MsgResponse)
 
+	specJsonBytes, err := json.Marshal(spec)
+	if err != nil {
+		return err
+	}
+
 	err = c.post(token, fullUrl, map[string]any{
 		"namespace":  namespace,
 		"dataSource": dataSource,
 		"name":       name,
-		"spec":       spec,
+		"spec":       string(specJsonBytes),
 	}, resp)
 	if err != nil {
 		return err

+ 7 - 1
client/data_source.go

@@ -1,6 +1,7 @@
 package client
 
 import (
+	"encoding/json"
 	"fmt"
 	"git.sxidc.com/go-tools/api_binding/http_binding/response"
 	"net/url"
@@ -20,11 +21,16 @@ func (c *Client) CreateDataSource(token string, baseUrl string, namespace string
 
 	resp := new(response.MsgResponse)
 
+	specJsonBytes, err := json.Marshal(spec)
+	if err != nil {
+		return err
+	}
+
 	err = c.post(token, fullUrl, map[string]any{
 		"namespace": namespace,
 		"name":      name,
 		"type":      typeStr,
-		"spec":      spec,
+		"spec":      string(specJsonBytes),
 	}, resp)
 	if err != nil {
 		return err

+ 13 - 2
client/sql.go

@@ -1,6 +1,7 @@
 package client
 
 import (
+	"encoding/json"
 	"fmt"
 	"git.sxidc.com/go-tools/api_binding/http_binding/response"
 	"net/url"
@@ -54,8 +55,13 @@ func (c *Client) ParseSqlSpec(token string, baseUrl string, spec map[string]any,
 		Parsed string `json:"parsed"`
 	})
 
+	specJsonBytes, err := json.Marshal(spec)
+	if err != nil {
+		return "", err
+	}
+
 	err = c.post(token, fullUrl, map[string]any{
-		"sql":           spec,
+		"sql":           string(specJsonBytes),
 		"executeParams": executeParams,
 	}, resp)
 	if err != nil {
@@ -77,11 +83,16 @@ func (c *Client) CreateSql(token string, baseUrl string, namespace string, dataS
 
 	resp := new(response.MsgResponse)
 
+	specJsonBytes, err := json.Marshal(spec)
+	if err != nil {
+		return err
+	}
+
 	err = c.post(token, fullUrl, map[string]any{
 		"namespace":  namespace,
 		"dataSource": dataSource,
 		"name":       name,
-		"sql":        spec,
+		"sql":        string(specJsonBytes),
 	}, resp)
 	if err != nil {
 		return err