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

Commit

Permalink
fix ListMembers response
Browse files Browse the repository at this point in the history
  • Loading branch information
luojielin committed Jul 14, 2021
1 parent 941745f commit e68e2d8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
17 changes: 16 additions & 1 deletion lib/management/organization_management_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package management
import (
"encoding/json"
"github.com/Authing/authing-go-sdk/lib/constant"
"github.com/Authing/authing-go-sdk/lib/enum"
"github.com/Authing/authing-go-sdk/lib/model"
jsoniter "github.com/json-iterator/go"
"log"
Expand All @@ -20,13 +21,27 @@ func (c *Client) ExportAll() ([]model.Node, error) {
}

func (c *Client) ListMembers(req *model.ListMemberRequest) (*model.Node, error) {
if req.SortBy == "" {
req.SortBy = enum.SortByCreatedAtAsc
}
if req.Page == 0 {
req.Page = 1
}
if req.Limit == 0 {
req.Limit = 10
}
variables := map[string]interface{}{
"id": req.NodeId,
"id": req.NodeId,
"limit": req.Limit,
"sortBy": req.SortBy,
"page": req.Page,
"includeChildrenNodes": req.IncludeChildrenNodes,
}
b, err := c.SendHttpRequest(c.Host+constant.CoreAuthingGraphqlPath, constant.HttpMethodPost, constant.NodeByIdWithMembersDocument, variables)
if err != nil {
return nil, err
}
log.Println("___" + string(b))
var response model.NodeByIdResponse
jsoniter.Unmarshal(b, &response)
return &response.Data.NodeById, nil
Expand Down
8 changes: 4 additions & 4 deletions lib/management/organization_management_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ func TestClient_ExportAll(t *testing.T) {
log.Printf("%+v\n", resp)
log.Println("==========获取节点成员==========")
var req = &model.ListMemberRequest{
NodeId: "60bdde221e3d90c0ac5efd16",
Page: 0,
Limit: 0,
IncludeChildrenNodes: false,
NodeId: "60cd9d3a4b96cfff16e7e5f4",
Page: 1,
Limit: 10,
IncludeChildrenNodes: true,
}
resp1, _ := client.ListMembers(req)
log.Printf("%+v\n", resp1)
Expand Down
9 changes: 5 additions & 4 deletions lib/model/vo_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
)

type ListMemberRequest struct {
NodeId string `json:"nodeId"`
Page int `json:"page"`
Limit int `json:"limit"`
IncludeChildrenNodes bool `json:"includeChildrenNodes"`
NodeId string `json:"nodeId"`
Page int `json:"page"`
Limit int `json:"limit"`
SortBy enum.SortByEnum `json:"sortBy"`
IncludeChildrenNodes bool `json:"includeChildrenNodes"`
}

type UserDetailData struct {
Expand Down

0 comments on commit e68e2d8

Please sign in to comment.