fix ivyz5773
This commit is contained in:
parent
85dea05704
commit
2fef946759
@ -3,7 +3,6 @@ package IVYZ
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"tianyuan-api/apps/api/internal/service"
|
||||
"tianyuan-api/apps/api/internal/svc"
|
||||
@ -12,6 +11,7 @@ import (
|
||||
"tianyuan-api/pkg/crypto"
|
||||
"tianyuan-api/pkg/errs"
|
||||
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
@ -113,28 +113,34 @@ func (l *IVYZ5733Logic) IVYZ5733(req *types.Request) (resp string, err *errs.App
|
||||
}
|
||||
return "", errs.ErrSystem
|
||||
}
|
||||
|
||||
// 使用gjson判断respData是否有status字段
|
||||
statusField := gjson.GetBytes(respData, "status")
|
||||
if !statusField.Exists() {
|
||||
logx.Errorf("羽山返回数据中缺少status字段: %s", string(respData))
|
||||
return "", errs.ErrNotFound
|
||||
}
|
||||
encryptData, aesEncrypt := crypto.AesEncrypt(respData, key)
|
||||
if aesEncrypt != nil {
|
||||
return "", errs.ErrSystem
|
||||
}
|
||||
// 解析加密后的数据
|
||||
var response map[string]interface{}
|
||||
unmarshalErr := json.Unmarshal([]byte(encryptData), &response)
|
||||
if unmarshalErr != nil {
|
||||
return "", errs.ErrSystem
|
||||
}
|
||||
|
||||
// 判断是否包含 "data" 字段
|
||||
responseData, dataOk := response["data"].([]interface{})
|
||||
if !dataOk || len(responseData) == 0 {
|
||||
return "", errs.ErrSystem
|
||||
}
|
||||
// 解析加密后的数据
|
||||
// var response map[string]interface{}
|
||||
// unmarshalErr := json.Unmarshal([]byte(encryptData), &response)
|
||||
// if unmarshalErr != nil {
|
||||
// return "", errs.ErrSystem
|
||||
// }
|
||||
|
||||
// // 判断是否包含 "data" 字段
|
||||
// responseData, dataOk := response["data"].([]interface{})
|
||||
// if !dataOk || len(responseData) == 0 {
|
||||
// return "", errs.ErrSystem
|
||||
// }
|
||||
|
||||
// 判断 "data" 中是否包含 "maritalStatus"
|
||||
maritalStatus := responseData[0].(map[string]interface{})["maritalStatus"]
|
||||
if maritalStatus == nil {
|
||||
return "", errs.ErrSystem
|
||||
}
|
||||
// maritalStatus := response.(map[string]interface{})["maritalStatus"]
|
||||
// if maritalStatus == nil {
|
||||
// return "", errs.ErrSystem
|
||||
// }
|
||||
return encryptData, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user