[feat] add GetModelPrefixForRelations, GetModelJoinsForRelations
This commit is contained in:
parent
61b40fef55
commit
c0df8cbaff
@ -49,3 +49,26 @@ func GetJoinResDependencies(root string, items []ResRelation) (dependencies []st
|
||||
|
||||
return dependencies
|
||||
}
|
||||
|
||||
func GetModelPrefixForRelations(model string, items []ResRelation) (result []any) {
|
||||
result = append([]any{model}, result...)
|
||||
for _, item := range items {
|
||||
if item.Code == model && (item.Type == "hasMany" || item.Type == "hasOne") {
|
||||
if item.Type == "hasMany" {
|
||||
result = append(result, 0)
|
||||
}
|
||||
return append(GetModelPrefixForRelations(item.RelationResource, items), result...)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func GetModelJoinsForRelations(model string, items []ResRelation) (result []string) {
|
||||
result = append([]string{model}, result...)
|
||||
for _, item := range items {
|
||||
if item.Code == model && (item.Type == "left" || item.Type == "right" || item.Type == "inner") {
|
||||
return append(GetModelJoinsForRelations(item.RelationResource, items), result...)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user