Skip to content

Commit b040654

Browse files
authored
enhance: add ORM tag to the entity result of command gen dao to make entity assignment more faster (#3454)
1 parent 505fc25 commit b040654

File tree

4 files changed

+27
-22
lines changed

4 files changed

+27
-22
lines changed

cmd/gf/internal/cmd/gendao/gendao_structure.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,14 @@ func generateStructFieldDefinition(
135135
" #" + gstr.CaseCamel(newFiledName),
136136
" #" + localTypeNameStr,
137137
}
138-
attrLines = append(attrLines, " #"+fmt.Sprintf(tagKey+`json:"%s"`, jsonTag))
139-
attrLines = append(attrLines, " #"+fmt.Sprintf(`description:"%s"`+tagKey, descriptionTag))
140-
attrLines = append(attrLines, " #"+fmt.Sprintf(`// %s`, formatComment(field.Comment)))
138+
attrLines = append(attrLines, fmt.Sprintf(` #%sjson:"%s"`, tagKey, jsonTag))
139+
// orm tag
140+
if !in.IsDo {
141+
// entity
142+
attrLines = append(attrLines, fmt.Sprintf(` #orm:"%s"`, field.Name))
143+
}
144+
attrLines = append(attrLines, fmt.Sprintf(` #description:"%s"%s`, descriptionTag, tagKey))
145+
attrLines = append(attrLines, fmt.Sprintf(` #// %s`, formatComment(field.Comment)))
141146

142147
for k, v := range attrLines {
143148
if in.NoJsonTag {

cmd/gf/internal/cmd/testdata/gendao/generated_user/model/entity/table_user.go

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/gf/internal/cmd/testdata/gendao/generated_user_type_mapping/model/entity/table_user.go

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/gf/internal/cmd/testdata/issue/2746/issue_2746.go

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)