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

Commit

Permalink
fix GetOrganizationChildren response
Browse files Browse the repository at this point in the history
  • Loading branch information
luojielin committed Jul 13, 2021
1 parent 68020b2 commit 941745f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
11 changes: 4 additions & 7 deletions lib/management/organization_management_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,18 @@ func (c *Client) GetOrganizationById(orgId string) (*model.Org, error) {
return &response.Data.Org, nil
}

func (c *Client) GetOrganizationChildren(nodeId string, depth int) (*[]model.Org, error) {
var result *[]model.Org
func (c *Client) GetOrganizationChildren(nodeId string, depth int) (*[]model.Node, error) {
var result *[]model.Node
variables := map[string]interface{}{
"nodeId": nodeId,
"depth": depth,
}
b, err := c.SendHttpRequest(c.Host+"/api/v2/orgs/children", constant.HttpMethodGet, "", variables)
if err != nil {
return nil, err
}
if err != nil {
return result, err
}
log.Println(string(b))
var response model.ListOrganizationResponse
var response model.GetOrganizationChildrenResponse
jsoniter.Unmarshal(b, &response)
return result, nil
return &response.Data, nil
}
6 changes: 3 additions & 3 deletions lib/management/organization_management_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func TestClient_GetOrganizationList(t *testing.T) {
client := NewClient(userPoolId, appSecret)
log.Println("==========获取用户池组织机构列表==========")
req := model.QueryListRequest{
Page: 1,
Limit: 10,
Page: 1,
Limit: 10,
SortBy: enum.SortByCreatedAtAsc,
}
resp, _ := client.GetOrganizationList(req)
Expand All @@ -51,7 +51,7 @@ func TestClient_GetOrganizationById(t *testing.T) {

func TestClient_GetOrganizationChildren(t *testing.T) {
client := NewClient(userPoolId, appSecret)
log.Println("==========获取第一层组织机构==========")
log.Println("==========获取第 n 层组织机构==========")
resp, _ := client.GetOrganizationChildren("60cd9d3a4b96cfff16e7e5f4", 1)
log.Printf("%+v\n", resp)
}
24 changes: 21 additions & 3 deletions lib/model/vo_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,30 @@ type ListUserResponse struct {
Data Users `json:"data"`
}

/*type OrganizationChildren struct {
Id string `json:"id"`
CreatedAt *string `json:"createdAt"`
UpdateAt *string `json:"updateAt"`
UserPoolId *string `json:"userPoolId"`
OrgId *string `json:"orgId"`
Name string `json:"name"`
Description *string `json:"description"`
Order *int64 `json:"order"`
Code *string `json:"code"`
}*/

type ListOrganizationResponse struct {
Message string `json:"message"`
Code int64 `json:"code"`
Data PaginatedOrgs `json:"data"`
}

type GetOrganizationChildrenResponse struct {
Message string `json:"message"`
Code int64 `json:"code"`
Data []Node `json:"data"`
}

type GetOrganizationByIdData struct {
Org Org `json:"org"`
}
Expand Down Expand Up @@ -84,8 +102,8 @@ type GetRoleUserListRequest struct {
}

type ValidateTokenRequest struct {
AccessToken string `json:"accessToken"`
IdToken string `json:"idToken"`
AccessToken string `json:"accessToken"`
IdToken string `json:"idToken"`
}

type ClientCredentialInput struct {
Expand All @@ -94,7 +112,7 @@ type ClientCredentialInput struct {
}

type GetAccessTokenByClientCredentialsRequest struct {
Scope string `json:"scope"`
Scope string `json:"scope"`
ClientCredentialInput *ClientCredentialInput `json:"client_credential_input"`
}

Expand Down

0 comments on commit 941745f

Please sign in to comment.