Skip to content

Commit

Permalink
feat: add getGroups(Boolean withTree) API (#78)
Browse files Browse the repository at this point in the history
* Add a check on whether the exp time has expired in AuthService

* Update AuthService.java

* Add a method to get the tree structure of the group

* Update GroupService.java

---------

Co-authored-by: Eric Luo <[email protected]>
  • Loading branch information
Bsheepcoder and hsluoyz authored Apr 21, 2024
1 parent badaf01 commit 34eecce
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/org/casbin/casdoor/service/GroupService.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ public List<Group> getGroups() throws IOException {
return response.getData();
}

public List<Group> getGroups(Boolean withTree) throws IOException {
if (!withTree) {
return getGroups();
}

CasdoorResponse<List<Group>, Object> response = doGet("get-groups",
Map.of("owner", config.organizationName, "withTree", "true"), new TypeReference<CasdoorResponse<List<Group>, Object>>() {
});
return response.getData();
}

public CasdoorResponse<String, Object> addGroup(Group group) throws IOException {
return modifyGroup(GroupOperations.ADD_GROUP, group, null);
}
Expand All @@ -65,4 +76,4 @@ private <T1, T2> CasdoorResponse<T1, T2> modifyGroup(GroupOperations method, Gro
new TypeReference<CasdoorResponse<T1, T2>>() {
});
}
}
}

0 comments on commit 34eecce

Please sign in to comment.