fix: dependency was added twice

This commit is contained in:
2025-03-15 21:14:22 +07:00
parent 6a55e106ab
commit 0cb667810a

View File

@@ -69,16 +69,19 @@ func GenerateScheme(model *model.Model, mkPath string) {
func processDependencies(fields []model.Field) []Dependency { func processDependencies(fields []model.Field) []Dependency {
var dependencies []Dependency var dependencies []Dependency
encountered := make(map[string]bool)
for _, field := range fields { for _, field := range fields {
dependency := field.Metadata.RelatedModel dep := field.Metadata.RelatedModel
if dependency == "" { if dep == "" || encountered[dep] {
continue continue
} }
encountered[dep] = true
dependencies = append(dependencies, Dependency{ dependencies = append(dependencies, Dependency{
ImportName: strings.ToUpper(dependency[:1]) + strings.ToLower(dependency[1:]) + "Service", ImportName: strings.ToUpper(dep[:1]) + strings.ToLower(dep[1:]) + "Service",
ServiceName: strings.ToLower(dependency) + "Service", ServiceName: strings.ToLower(dep) + "Service",
LowerName: strings.ToLower(dependency), LowerName: strings.ToLower(dep),
FieldName: field.Name, FieldName: field.Name,
}) })