This commit is contained in:
谢小军
2019-12-13 19:52:15 +08:00
parent 3646031889
commit da4332286f
8 changed files with 66 additions and 15 deletions

View File

@@ -5,8 +5,8 @@ import (
"github.com/xxjwxc/gormt/data/view/model/genmysql"
)
// GetModel get model interface. 获取model接口
func GetModel() model.IModel {
// GetMysqlModel get model interface. 获取model接口
func GetMysqlModel() model.IModel {
//now just support mysql
return &genmysql.MySQLModel
}

View File

@@ -19,20 +19,20 @@ func Execute() {
// orm.Where("nickname = ?", "ticket_001").Find(&tt)
// fmt.Println(tt)
modeldb := GetModel()
modeldb := GetMysqlModel()
pkg := modeldb.GenModel()
pkg.PackageName = modeldb.GetPkgName()
str := model.Generate(pkg)
list := model.Generate(pkg)
path := config.GetOutDir() + "/" + modeldb.GetDbName() + ".go"
tools.WriteFile(path,
[]string{str}, true)
for _, v := range list {
path := config.GetOutDir() + "/" + v.FileName
tools.WriteFile(path, []string{v.FileCtx}, true)
fmt.Println("formatting differs from goimport's:")
cmd, _ := exec.Command("goimports", "-l", "-w", path).Output()
fmt.Println(string(cmd))
fmt.Println("formatting differs from goimport's:")
cmd, _ := exec.Command("goimports", "-l", "-w", path).Output()
fmt.Println(string(cmd))
fmt.Println("formatting differs from gofmt's:")
cmd, _ = exec.Command("gofmt", "-l", "-w", path).Output()
fmt.Println(string(cmd))
fmt.Println("formatting differs from gofmt's:")
cmd, _ = exec.Command("gofmt", "-l", "-w", path).Output()
fmt.Println(string(cmd))
}
}