gorm tools

This commit is contained in:
xiexiaojun
2019-06-01 17:12:45 +08:00
parent 696fcb84f7
commit b42b4931b3
12 changed files with 430 additions and 105 deletions

View File

@@ -1,15 +1,33 @@
package gtools
import (
"github.com/xie1xiao1jun/gorm-tools/data/config"
"fmt"
"os/exec"
"github.com/xie1xiao1jun/gormt/data/config"
"github.com/xie1xiao1jun/public/mysqldb"
"github.com/xie1xiao1jun/public/tools"
)
//开始执行
func Execute() {
orm := mysqldb.OnInitDBOrm(config.GetMysqlConStr())
defer orm.OnDestoryDB()
OnGetPackageInfo(orm, OnGetTables(orm))
// var tt oauth_db.UserInfoTbl
// tt.Nickname = "ticket_001"
// orm.Where("nickname = ?", "ticket_001").Find(&tt)
// fmt.Println(tt)
pkg := OnGetPackageInfo(orm, OnGetTables(orm))
pkg.SetPackage(config.GetMysqlDbInfo().Database)
str := pkg.Generate()
path := config.GetOutDir() + "/" + config.GetMysqlDbInfo().Database + "/" + config.GetMysqlDbInfo().Database + ".go"
tools.WriteFile(path,
[]string{str}, true)
cmd, _ := exec.Command("gofmt", "-l", "-w", path).Output()
fmt.Println(string(cmd))
}