修复用户同步请求数据问题

This commit is contained in:
junleea 2024-12-15 18:02:10 +08:00
parent 27858d41e7
commit 9d01e83d71
1 changed files with 5 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import (
"io"
"io/ioutil"
"net/http"
"strconv"
"strings"
"videoplayer/proto"
)
@ -159,15 +160,16 @@ func SyncDataFromMasterReq2(url string, data proto.SyncUserReq) (proto.UserSync,
}
defer resp.Body.Close()
//解析数据
var m map[string]interface{}
var m map[string]string
err = json.NewDecoder(resp.Body).Decode(&m)
if err != nil {
return res, err
}
if m["code"].(float64) != 0 {
code, _ := strconv.Atoi(m["code"])
if code != 0 {
return res, err
}
err = json.Unmarshal([]byte(m["data"].(string)), &res)
err = json.Unmarshal([]byte(m["data"]), &res)
if err != nil {
fmt.Println("SyncDataFromMasterReq2 error decode data:", err)
return res, err