This commit is contained in:
2025-08-26 21:40:02 +08:00
parent 958f23487c
commit 4031277a91
2 changed files with 66 additions and 3 deletions

View File

@@ -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处理方法
@@ -34,7 +36,7 @@ func ProcessIVYZ4E8BRequest(ctx context.Context, params []byte, deps *processors
reqData := map[string]interface{}{ reqData := map[string]interface{}{
"data": map[string]interface{}{ "data": map[string]interface{}{
"name": encryptedName, "name": encryptedName,
"idNo": encryptedIDCard, "idNo": encryptedIDCard,
}, },
} }
@@ -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
}

View File

@@ -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
} }