Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
fix: 修复批量设置扩展字段失败的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
luojielin committed Aug 15, 2022
1 parent 2b00c5f commit 259c5d9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
9 changes: 8 additions & 1 deletion lib/management/udf_management_client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package management

import (
"encoding/json"
"errors"
"github.com/Authing/authing-go-sdk/lib/constant"
"github.com/Authing/authing-go-sdk/lib/model"
Expand Down Expand Up @@ -111,7 +112,13 @@ func (c *Client) SetUdvBatch(id string, targetType model.EnumUDFTargetType, udv

variables["targetType"] = targetType
variables["targetId"] = id
variables["udvList"] = udv
var reqUdv []model.KeyValuePair
for _, v := range *udv {
v1, _ := json.Marshal(&v.Value)
v.Value = string(v1)
reqUdv = append(reqUdv, v)
}
variables["udvList"] = reqUdv

b, err := c.SendHttpRequest(c.Host+constant.CoreAuthingGraphqlPath, http.MethodPost, constant.SetRoleUdfValueDocument, variables)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions lib/management/udf_management_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ func TestClient_SetUdvBatch(t *testing.T) {
client := NewClient(userPoolId, appSecret)
log.Println("==========某对象自定义字段列表==========")

resp, err := client.SetUdvBatch("616d41b7410a33da0cb70e65", model.EnumUDFTargetTypeUSER, &[]model.KeyValuePair{
{Key: "goSDK", Value: "goSDK"},
resp, err := client.SetUdvBatch("61bc4f2e083e0e9b1634e1f0", model.EnumUDFTargetTypeUSER, &[]model.KeyValuePair{
{Key: "school", Value: "sss111"},
{Key: "student", Value: false},
})
if err != nil {
fmt.Println(err)
Expand Down
6 changes: 3 additions & 3 deletions lib/management/user_management_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@ func TestClient_SetUserUdfValue(t *testing.T) {
client := NewClient(userPoolId, appSecret)
log.Println("==========批量查询用户自定义字段==========")
udv := model.KeyValuePair{
Key: "runCount",
Value: 23,
Key: "school",
Value: "sss1",
}
resp, err := client.SetUserUdfValue("621dcbede60e7b7eda97d82a", &udv)
resp, err := client.SetUserUdfValue("61bc4f2e083e0e9b1634e1f0", &udv)
log.Println(resp)
log.Println(err)
}
Expand Down

0 comments on commit 259c5d9

Please sign in to comment.