mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-12 11:13:21 +02:00
add ParentGroup field and related LoadParentGroup method to Group struct
This commit is contained in:
parent
ade1c082eb
commit
9fb94a8be1
@ -22,6 +22,7 @@ type Group struct {
|
||||
Avatar string `xorm:"VARCHAR(64)"`
|
||||
|
||||
ParentGroupID int64 `xorm:"INDEX DEFAULT NULL"`
|
||||
ParentGroup *Group `xorm:"-"`
|
||||
Subgroups GroupList `xorm:"-"`
|
||||
}
|
||||
|
||||
@ -68,6 +69,18 @@ func (g *Group) LoadAttributes(ctx context.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return g.LoadParentGroup(ctx)
|
||||
}
|
||||
|
||||
func (g *Group) LoadParentGroup(ctx context.Context) error {
|
||||
if g.ParentGroup != nil {
|
||||
return nil
|
||||
}
|
||||
parentGroup, err := GetGroupByID(ctx, g.ParentGroupID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
g.ParentGroup = parentGroup
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user