diff --git a/base/res_relation.go b/base/res_relation.go index 1369398..b656ea1 100644 --- a/base/res_relation.go +++ b/base/res_relation.go @@ -15,3 +15,28 @@ type ResRelation struct { } type GetResRelations func(categoryUuid string) []ResRelation + +// 资源关联依赖 +func GetJoinResDependencies(code string, items []ResRelation) (dependencies []string) { + dependencies = []string{code} + + for { + done := true + for _, item := range items { + if item.Type != "inner" && item.Type != "left" && item.Type != "right" { + continue + } + + if dependencies[len(dependencies)-1] == item.Code && item.RelationResource != "" { + done = false + dependencies = append(dependencies, item.RelationResource) + } + } + + if done { + break + } + } + + return dependencies +}