fix go model gen column name

master
xxjwxc 4 years ago
parent 60fb4511cb
commit 8f873848b4

@ -164,12 +164,25 @@ func (s *GenStruct) GenerateColumnName() []string {
} }
data.StructName = s.Name data.StructName = s.Name
for _, v := range s.Em { for _, v := range s.Em {
data.Em = append(data.Em, struct { if strings.EqualFold(v.Type, "gorm.Model") { // gorm model
ColumnName string data.Em = append(data.Em, []struct {
StructName string ColumnName string
}{ColumnName: v.ColumnName, StructName string
StructName: v.Name, }{
}) {ColumnName: "id", StructName: "ID"},
{ColumnName: "created_at", StructName: "CreatedAt"},
{ColumnName: "updated_at", StructName: "UpdatedAt"},
{ColumnName: "deleted_at", StructName: "DeletedAt"},
}...)
} else {
data.Em = append(data.Em, struct {
ColumnName string
StructName string
}{ColumnName: v.ColumnName,
StructName: v.Name,
})
}
} }
var buf bytes.Buffer var buf bytes.Buffer

Loading…
Cancel
Save