This commit is contained in:
2026-08-16 01:19:10 +08:00
parent c4b114762b
commit c554152f4f
43 changed files with 1311 additions and 318 deletions
+12 -1
View File
@@ -36,9 +36,20 @@ func (uc *AuthorityUsecase) AuthorityTree(ctx context.Context) ([]*Authority, er
if item.ParentID != nil && *item.ParentID != 0 && byID[*item.ParentID] != nil {
parent := byID[*item.ParentID]
parent.Children = append(parent.Children, item)
} else {
} else if item.ParentID == nil || *item.ParentID == 0 {
roots = append(roots, item)
}
}
// In GVA strict-authority mode a non-root actor receives its direct
// children as the top-level result even though their parent is omitted.
if len(roots) == 0 {
if actor, ok := ActorFromContext(ctx); ok {
for _, item := range items {
if item.ParentID != nil && *item.ParentID == actor.AuthorityID {
roots = append(roots, item)
}
}
}
}
return roots, nil
}