[feat] 新增 GetJoinResDependencies, 获取 join 依赖关系

This commit is contained in:
what-00 2023-04-13 10:03:21 +08:00
parent d5c3c4704a
commit 9b71c96e61

View File

@ -15,3 +15,28 @@ type ResRelation struct {
} }
type GetResRelations func(categoryUuid string) []ResRelation 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
}