This commit is contained in:
邹宗楠
2023-06-15 09:13:04 +08:00
parent 65976332fc
commit af159cdee7

View File

@@ -3,6 +3,7 @@ package topsdk
import (
"bytes"
"fmt"
util2 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/util"
"io"
"io/ioutil"
"log"
@@ -12,7 +13,6 @@ import (
"net/url"
"strings"
"time"
util2 "topsdk/util"
)
type TopClient struct {
@@ -34,7 +34,6 @@ type HttpTransportConfig struct {
MaxIdleConnsPerHost int
IdleConnTimeout int64
MaxConnsPerHost int
}
func NewDefaultTopClient(AppKey string, AppSecret string, ServerUrl string, connectTimeount int64, readTimeout int64) TopClient {
@@ -49,7 +48,6 @@ func NewDefaultTopClient(AppKey string,AppSecret string,ServerUrl string, connec
}
func NewTopClientWithConfig(AppKey string, AppSecret string, ServerUrl string, connectTimeount int64, readTimeout int64, httpTransportConfig *HttpTransportConfig) TopClient {
httpClient := http.Client{
Timeout: time.Duration(connectTimeount) * time.Millisecond,
@@ -80,9 +78,6 @@ func NewTopClientWithConfig(AppKey string,AppSecret string,ServerUrl string, con
}
}
func (client *TopClient) ExecuteWithSession(method string, data map[string]interface{}, fileData map[string]interface{}, session string) (string, error) {
var publicParam = make(map[string]interface{})
publicParam["method"] = method
@@ -124,12 +119,12 @@ func doPost(urlPath string,data map[string]interface{},httpClient *http.Client)
if resp != nil {
defer resp.Body.Close()
}
if(err != nil){
if err != nil {
log.Println("http.PostForm error", err)
return "", err
}
body, err := ioutil.ReadAll(resp.Body)
if(err != nil){
if err != nil {
log.Println("ioutil.ReadAll", err)
return "", err
}
@@ -172,7 +167,7 @@ func doPostWithFile(urlPath string,data map[string]interface{},fileData map[stri
}
err := writer.Close()
if(err != nil){
if err != nil {
return "", err
}
@@ -190,10 +185,6 @@ func doPostWithFile(urlPath string,data map[string]interface{},fileData map[stri
return string(body), nil
}
func (client *TopClient) Execute(method string, data map[string]interface{}, fileData map[string]interface{}) (string, error) {
return client.ExecuteWithSession(method, data, fileData, "")
}