添加gorm的model结构一个表名的入口
This commit is contained in:
@@ -342,11 +342,12 @@ func GenFromPath(mdir string, cols []Column, tableName string, tableComment stri
|
||||
|
||||
fcontent += importstr + ")\n"
|
||||
fcontent += fmt.Sprintf(structstr, tableName, tableComment, pTableName, fieldstr)
|
||||
modelstr := fmt.Sprintf(`type %sModel struct {db *gorm.DB}`, pTableName)
|
||||
modelstr := fmt.Sprintf(`type %sModel struct {db *gorm.DB
|
||||
name string}`, pTableName)
|
||||
fcontent += modelstr
|
||||
fcontent += "\n"
|
||||
|
||||
newfuncstr := fmt.Sprintf(`func New%sModel(db *gorm.DB) *%sModel {return &%sModel{db}}`, pTableName, pTableName, pTableName)
|
||||
newfuncstr := fmt.Sprintf(`func New%sModel(db *gorm.DB) *%sModel {return &%sModel{db:db,name:"%s"}}`, pTableName, pTableName, pTableName, tableName)
|
||||
fcontent += newfuncstr
|
||||
fcontent += "\n"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user