From d70e2c2a2b2d2192e2b9ebfdbddaee1d5a6c8a5a Mon Sep 17 00:00:00 2001 From: lonewolf Date: Tue, 3 Mar 2015 23:35:46 +0800 Subject: [PATCH] add tableName to model file --- g_appcode.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/g_appcode.go b/g_appcode.go index b033ab6..9d848d5 100644 --- a/g_appcode.go +++ b/g_appcode.go @@ -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}})) }