Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cmd/gf): add interface functions generating for embedded struct of logic struct in command gen service #3802

Merged
merged 18 commits into from
Dec 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix bug
  • Loading branch information
joy999 committed Sep 24, 2024
commit 4a40b14dbd5b66dc5782958f640dab877a65ad9c
26 changes: 12 additions & 14 deletions cmd/gf/internal/cmd/genservice/genservice_ast_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,20 @@ func (c CGenService) parseItemsInSrc(filePath string) (pkgItems []pkgItem, struc
var structEmbeddedStruct []string
for _, field := range st.Fields.List {
if len(field.Names) == 0 { // 匿名字段
if embeddedStruct, err := c.astExprToString(field.Type); err == nil && embeddedStruct != "" {
if !checkValidStructName(embeddedStruct) {
continue
var embeddedStruct string
if _, ok := field.Type.(*ast.Ident); ok {
if embeddedStruct, err = c.astExprToString(field.Type); err != nil {
embeddedStruct = ""
}
} else if ptr, ok := field.Type.(*ast.StarExpr); ok {
if embeddedStruct, err = c.astExprToString(ptr.X); err != nil {
embeddedStruct = ""
}
structEmbeddedStruct = append(structEmbeddedStruct, embeddedStruct)
}

// if _, ok := field.Type.(*ast.Ident); ok {
// if parent, err = c.astExprToString(field.Type); err != nil {
// parent = ""
// }
// } else if ptr, ok := field.Type.(*ast.StarExpr); ok {
// if parent, err = c.astExprToString(ptr.X); err != nil {
// parent = ""
// }
// }
if embeddedStruct == "" || !checkValidStructName(embeddedStruct) {
continue
}
structEmbeddedStruct = append(structEmbeddedStruct, embeddedStruct)
}
}
if len(structEmbeddedStruct) > 0 {
Expand Down
Loading