1
0
mirror of https://github.com/beego/bee.git synced 2024-11-22 05:00:54 +00:00

import package for no-pk models

This commit is contained in:
ZhengYang 2014-08-19 17:43:08 +08:00
parent c487e9d6f7
commit 82b7ab3e31

View File

@ -487,10 +487,13 @@ func writeModelFiles(tables []*Table, mPath string, selectedTables map[string]bo
fileStr = strings.Replace(fileStr, "{{modelName}}", camelCase(tb.Name), -1)
// if table contains time field, import time.Time package
timePkg := ""
importTimePkg := ""
if tb.ImportTimePkg {
timePkg = "\"time\"\n"
importTimePkg = "import \"time\"\n"
}
fileStr = strings.Replace(fileStr, "{{timePkg}}", timePkg, -1)
fileStr = strings.Replace(fileStr, "{{importTimePkg}}", importTimePkg, -1)
if _, err := f.WriteString(fileStr); err != nil {
ColorLog("[ERRO] Could not write model file to %s\n", fpath)
os.Exit(2)
@ -707,6 +710,7 @@ func getPackagePath(curpath string) (packpath string) {
const (
STRUCT_MODEL_TPL = `package models
{{importTimePkg}}
{{modelStruct}}
`