mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-02 11:20:18 +08:00
feat: complete group tree (#1967)
* feat: complete group tree * feat: ui * fix: i18n * refactor code * fix: support remove user from group * fix: format code * Update organization.go * Update organization.go * Update user_group.go --------- Co-authored-by: hsluoyz <hsluoyz@qq.com>
This commit is contained in:
@ -22,6 +22,7 @@ import (
|
||||
"github.com/casdoor/casdoor/cred"
|
||||
"github.com/casdoor/casdoor/i18n"
|
||||
"github.com/casdoor/casdoor/util"
|
||||
"github.com/xorm-io/builder"
|
||||
"github.com/xorm-io/core"
|
||||
)
|
||||
|
||||
@ -75,11 +76,18 @@ func GetOrganizationCount(owner, field, value string) (int64, error) {
|
||||
return session.Count(&Organization{})
|
||||
}
|
||||
|
||||
func GetOrganizations(owner string) ([]*Organization, error) {
|
||||
func GetOrganizations(owner string, name ...string) ([]*Organization, error) {
|
||||
organizations := []*Organization{}
|
||||
err := adapter.Engine.Desc("created_time").Find(&organizations, &Organization{Owner: owner})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if name != nil && len(name) > 0 {
|
||||
err := adapter.Engine.Desc("created_time").Where(builder.In("name", name)).Find(&organizations)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
err := adapter.Engine.Desc("created_time").Find(&organizations, &Organization{Owner: owner})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return organizations, nil
|
||||
|
Reference in New Issue
Block a user