Skip to content

Commit 6adede3

Browse files
committed
✨ Compatibility GoParamDefinition and Save
1 parent d4fbcf8 commit 6adede3

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

example/goframe/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
type User struct {
88
g.Meta `orm:"table:goframe_users, do:true"`
9-
ID uint // 主键
9+
ID uint // 主键
1010
Name string `orm:"user_name"` // 姓名
1111
Email *string // 邮箱
1212
Age int32 // 年龄

src/main/java/com/github/maiqingqiang/goormhelper/orm/ORMCompletionProvider.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,18 @@ protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull
136136
handleGoTypeReferenceExpression(parameters, result, descriptor, goCompositeLit.getTypeReferenceExpression());
137137
}
138138
}
139+
} else if(goReferenceExpression.resolve() instanceof GoParamDefinition goParamDefinition){
140+
GoType goType = goParamDefinition.getGoTypeInner(ResolveState.initial());
141+
142+
if (goType instanceof GoArrayOrSliceType goArrayOrSliceType) {
143+
goType = goArrayOrSliceType.getType();
144+
}
145+
146+
if (goType instanceof GoPointerType goPointerType) {
147+
goType = goPointerType.getType();
148+
}
149+
150+
handleGoType(parameters, result, descriptor, goType);
139151
}
140152
} else if (argument instanceof GoCompositeLit goCompositeLit) {
141153
handleGoTypeReferenceExpression(parameters, result, descriptor, goCompositeLit.getTypeReferenceExpression());

src/main/java/com/github/maiqingqiang/goormhelper/orm/gorm/GormTypes.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,16 @@ public interface GormTypes {
6666
Map.entry(GoMethodDescriptor.of("(*gorm.io/gorm.DB).Take"), 0),
6767
Map.entry(GoMethodDescriptor.of("(*gorm.io/gorm.DB).Last"), 0),
6868
Map.entry(GoMethodDescriptor.of("(*gorm.io/gorm.DB).Create"), 0),
69+
Map.entry(GoMethodDescriptor.of("(*gorm.io/gorm.DB).Save"), 0),
6970
Map.entry(GoMethodDescriptor.of("(*github.com/jinzhu/gorm.DB).First"), 0),
7071
Map.entry(GoMethodDescriptor.of("(*github.com/jinzhu/gorm.DB).Find"), 0),
7172
Map.entry(GoMethodDescriptor.of("(*github.com/jinzhu/gorm.DB).Delete"), 0),
7273
Map.entry(GoMethodDescriptor.of("(*github.com/jinzhu/gorm.DB).FirstOrInit"), 0),
7374
Map.entry(GoMethodDescriptor.of("(*github.com/jinzhu/gorm.DB).FirstOrCreate"), 0),
7475
Map.entry(GoMethodDescriptor.of("(*github.com/jinzhu/gorm.DB).Take"), 0),
7576
Map.entry(GoMethodDescriptor.of("(*github.com/jinzhu/gorm.DB).Last"), 0),
76-
Map.entry(GoMethodDescriptor.of("(*github.com/jinzhu/gorm.DB).Create"), 0)
77+
Map.entry(GoMethodDescriptor.of("(*github.com/jinzhu/gorm.DB).Create"), 0),
78+
Map.entry(GoMethodDescriptor.of("(*github.com/jinzhu/gorm.DB).Save"), 0)
7779
);
7880
GoCallableDescriptorSet OTHER_SCHEMA_CALLABLES_SET = new GoCallableDescriptorSet(OTHER_SCHEMA_CALLABLES.keySet());
7981

0 commit comments

Comments
 (0)