fix
This commit is contained in:
@@ -9,6 +9,8 @@ import (
|
|||||||
"tyapi-server/internal/domains/api/dto"
|
"tyapi-server/internal/domains/api/dto"
|
||||||
"tyapi-server/internal/domains/api/services/processors"
|
"tyapi-server/internal/domains/api/services/processors"
|
||||||
"tyapi-server/internal/infrastructure/external/westdex"
|
"tyapi-server/internal/infrastructure/external/westdex"
|
||||||
|
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProcessIVYZ4E8BRequest IVYZ4E8B API处理方法
|
// ProcessIVYZ4E8BRequest IVYZ4E8B API处理方法
|
||||||
@@ -48,5 +50,35 @@ func ProcessIVYZ4E8BRequest(ctx context.Context, params []byte, deps *processors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return respBytes, nil
|
// 解析响应,提取data字段中的hyzk
|
||||||
|
var respMap map[string]interface{}
|
||||||
|
if err := json.Unmarshal(respBytes, &respMap); err != nil {
|
||||||
|
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
dataStr, ok := respMap["data"].(string)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("%s: data字段格式错误", processors.ErrDatasource)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用gjson解析data字符串
|
||||||
|
hyzk := ""
|
||||||
|
{
|
||||||
|
result := gjson.Get(dataStr, "hyzk")
|
||||||
|
if !result.Exists() {
|
||||||
|
return nil, fmt.Errorf("%s: data中缺少hyzk字段", processors.ErrDatasource)
|
||||||
|
}
|
||||||
|
hyzk = result.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回格式为 {"status": hyzk}
|
||||||
|
resp := map[string]interface{}{
|
||||||
|
"status": hyzk,
|
||||||
|
}
|
||||||
|
finalBytes, err := json.Marshal(resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return finalBytes, nil
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,8 @@ import (
|
|||||||
"tyapi-server/internal/domains/api/dto"
|
"tyapi-server/internal/domains/api/dto"
|
||||||
"tyapi-server/internal/domains/api/services/processors"
|
"tyapi-server/internal/domains/api/services/processors"
|
||||||
"tyapi-server/internal/infrastructure/external/westdex"
|
"tyapi-server/internal/infrastructure/external/westdex"
|
||||||
|
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProcessIVYZ7F2ARequest IVYZ7F2A API处理方法
|
// ProcessIVYZ7F2ARequest IVYZ7F2A API处理方法
|
||||||
@@ -59,6 +61,35 @@ func ProcessIVYZ7F2ARequest(ctx context.Context, params []byte, deps *processors
|
|||||||
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err)
|
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var respMap map[string]interface{}
|
||||||
|
if err := json.Unmarshal(respBytes, &respMap); err != nil {
|
||||||
|
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
dataStr, ok := respMap["data"].(string)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("%s: data字段格式错误", processors.ErrDatasource)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用gjson解析data字符串
|
||||||
|
hyzk := ""
|
||||||
|
{
|
||||||
|
result := gjson.Get(dataStr, "hyzk")
|
||||||
|
if !result.Exists() {
|
||||||
|
return nil, fmt.Errorf("%s: data中缺少hyzk字段", processors.ErrDatasource)
|
||||||
|
}
|
||||||
|
hyzk = result.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回格式为 {"status": hyzk}
|
||||||
|
resp := map[string]interface{}{
|
||||||
|
"status": hyzk,
|
||||||
|
}
|
||||||
|
finalBytes, err := json.Marshal(resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return finalBytes, nil
|
||||||
return respBytes, nil
|
return respBytes, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user