Skip to content

Commit

Permalink
Remove json in GetPaginationPermissions()
Browse files Browse the repository at this point in the history
  • Loading branch information
hsluoyz committed Aug 19, 2023
1 parent ca067a9 commit 10ffa88
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions casdoorsdk/permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package casdoorsdk

import (
"encoding/json"
"errors"
"fmt"
"strconv"
)
Expand Down Expand Up @@ -109,16 +110,11 @@ func (c *Client) GetPaginationPermissions(p int, pageSize int, queryMap map[stri
return nil, 0, fmt.Errorf(response.Msg)
}

bytes, err := json.Marshal(response.Data)
if err != nil {
return nil, 0, err
permissions, ok := response.Data.([]*Permission)
if !ok {
return nil, 0, errors.New("response data format is incorrect")
}

var permissions []*Permission
err = json.Unmarshal(bytes, &permissions)
if err != nil {
return nil, 0, err
}
return permissions, int(response.Data2.(float64)), nil
}

Expand Down

0 comments on commit 10ffa88

Please sign in to comment.