This commit is contained in:
2024-12-30 19:09:10 +08:00
parent 7309ef704d
commit e96f8a5c8d
4 changed files with 10 additions and 5 deletions

View File

@@ -9,7 +9,6 @@ import (
"github.com/tidwall/gjson"
"github.com/zeromicro/go-zero/core/logx"
"io"
"log"
"net/http"
"net/url"
"qnc-server/app/user/cmd/api/internal/config"
@@ -364,7 +363,6 @@ func (a *ApiRequestService) ProcessG35SC01Request(params []byte) ([]byte, error)
},
}
resp, callApiErr := a.westDexService.CallAPI("G35SC01", request)
log.Println(string(resp))
if callApiErr != nil {
return nil, callApiErr
}
@@ -386,13 +384,16 @@ func (a *ApiRequestService) ProcessG35SC01Request(params []byte) ([]byte, error)
return nil, fmt.Errorf("内层 data 字段不存在或类型错误")
}
if innerData == "" || innerData == "{}" || innerData == "[]" {
innerData = "{}"
}
// 第四步:解析内层 data 的 JSON 字符串
var finalDataMap map[string]interface{}
if err := json.Unmarshal([]byte(innerData), &finalDataMap); err != nil {
return nil, fmt.Errorf("解析内层 data 字段失败: %v", err)
}
// 将最终的 JSON 对象编码为字节数组返回
finalDataBytes, err := json.Marshal(finalDataMap)
if err != nil {
return nil, fmt.Errorf("编码最终的 JSON 对象失败: %v", err)