add tableName to model file

This commit is contained in:
lonewolf 2015-03-03 23:35:46 +08:00
parent 7f313ac0eb
commit d70e2c2a2b
1 changed files with 5 additions and 0 deletions

View File

@ -761,6 +761,7 @@ func writeModelFiles(tables []*Table, mPath string, selectedTables map[string]bo
}
fileStr := strings.Replace(template, "{{modelStruct}}", tb.String(), 1)
fileStr = strings.Replace(fileStr, "{{modelName}}", camelCase(tb.Name), -1)
fileStr = strings.Replace(fileStr, "{{tableName}}", tb.Name, -1)
// if table contains time field, import time.Time package
timePkg := ""
importTimePkg := ""
@ -1003,6 +1004,10 @@ import (
{{modelStruct}}
func (t *{{modelName}}) TableName() string {
return "{{tableName}}"
}
func init() {
orm.RegisterModel(new({{modelName}}))
}