From 2b337fa6e928c209aafe616dcdde351595c63c1e Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期三, 20 一月 2021 16:06:45 +0800
Subject: [PATCH] 使用reply解析doReq返回的结果

---
 sbusClient.go |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/sbusClient.go b/sbusClient.go
index 9deb67c..b1e91df 100644
--- a/sbusClient.go
+++ b/sbusClient.go
@@ -36,6 +36,12 @@
 	Body        			[]byte              	`json:"body"`
 }
 
+type reply struct {
+	Success 			bool 						`json:"success"`
+	Msg 				string 						`json:"msg"`
+	Data 				interface{} 				`json:"data"`
+}
+
 func (sc SBusClient) DoGetRequest(url string, params map[string]string, headers map[string]string) ([]byte, error) {
 	if sc.nodes == nil || len(sc.nodes) == 0 {
 		return nil, errors.New("invalid netNodes")
@@ -165,13 +171,7 @@
 		return nil, fmt.Errorf("doReq s.SendandrecvTimeout result n:%d", n)
 	} else {
 		if len(ret) > 0 {
-			var retMsg MsgInfo
-			err = json.Unmarshal(ret[0].Data, &retMsg)
-			if err != nil {
-				logPrint("doReq unmarshal to MsgInfo err:", err)
-				return nil, err
-			}
-			return retMsg.Body, nil
+			return ret[0].Data, nil
 		}
 		return nil, fmt.Errorf("no any response")
 	}

--
Gitblit v1.8.0