Skip to content

Commit 2c2b91f

Browse files
committed
feat: query struct comment
1 parent 2ca11ea commit 2c2b91f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

internal/generate/query.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@ func (b *QueryStructMeta) StructComment() string {
161161
return `mapped from object`
162162
}
163163

164+
// QueryStructComment query struct comment
165+
func (b *QueryStructMeta) QueryStructComment() string {
166+
if b.TableComment != "" {
167+
return fmt.Sprintf(`// %s %s`, b.QueryStructName, b.TableComment)
168+
}
169+
170+
return ``
171+
}
172+
164173
// ReviseDIYMethod check diy method duplication name
165174
func (b *QueryStructMeta) ReviseDIYMethod() error {
166175
var duplicateMethodName []string

internal/template/struct.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package template
33
const (
44
// TableQueryStruct table query struct
55
TableQueryStruct = createMethod + `
6-
// {{.QueryStructName}} {{.StructComment}}
6+
{{.QueryStructComment}}
77
type {{.QueryStructName}} struct {
88
{{.QueryStructName}}Do
99
` + fields + `
@@ -12,7 +12,7 @@ const (
1212

1313
// TableQueryStructWithContext table query struct with context
1414
TableQueryStructWithContext = createMethod + `
15-
// {{.QueryStructName}} {{.StructComment}}
15+
{{.QueryStructComment}}
1616
type {{.QueryStructName}} struct {
1717
{{.QueryStructName}}Do {{.QueryStructName}}Do
1818
` + fields + `

0 commit comments

Comments
 (0)