feat: optimize get-groups API and GroupListPage (#3518)

* fix: optimize get-groups api and GroupListPage

* fix: fix linter issue
This commit is contained in:
DacongDA
2025-01-23 09:47:39 +08:00
committed by GitHub
parent 9701818a6e
commit a5a627f92e
3 changed files with 58 additions and 57 deletions

View File

@ -70,15 +70,33 @@ func (c *ApiController) GetGroups() {
if err != nil {
c.ResponseError(err.Error())
return
} else {
err = object.ExtendGroupsWithUsers(groups)
if err != nil {
c.ResponseError(err.Error())
return
}
groupsHaveChildrenMap, err := object.GetGroupsHaveChildrenMap(groups)
if err != nil {
c.ResponseError(err.Error())
return
}
for _, group := range groups {
_, ok := groupsHaveChildrenMap[group.Name]
if ok {
group.HaveChildren = true
}
c.ResponseOk(groups, paginator.Nums())
parent, ok := groupsHaveChildrenMap[group.ParentId]
if ok {
group.ParentName = parent.DisplayName
}
}
err = object.ExtendGroupsWithUsers(groups)
if err != nil {
c.ResponseError(err.Error())
return
}
c.ResponseOk(groups, paginator.Nums())
}
}