/********************************************** ** @Des: This file ... ** @Author: haodaquan ** @Date: 2017-09-08 00:18:02 ** @Last Modified by: haodaquan ** @Last Modified time: 2017-09-16 17:26:48 ***********************************************/ package models import ( "github.com/astaxie/beego" _ "github.com/go-sql-driver/mysql" ) // //func Init() { // dbhost := beego.AppConfig.String("db.host") // dbport := beego.AppConfig.String("db.port") // dbuser := beego.AppConfig.String("db.user") // dbpassword := beego.AppConfig.String("db.password") // dbname := beego.AppConfig.String("db.name") // timezone := beego.AppConfig.String("db.timezone") // if dbport == "" { // dbport = "3306" // } // dsn := dbuser + ":" + dbpassword + "@tcp(" + dbhost + ":" + dbport + ")/" + dbname + "?charset=utf8" // // fmt.Println(dsn) // // if timezone != "" { // dsn = dsn + "&loc=" + url.QueryEscape(timezone) // } // orm.RegisterDataBase("default", "mysql", dsn) // orm.RegisterModel(new(backgroundm.Auth), new(backgroundm.Role), new(backgroundm.RoleAuth), new(backgroundm.Admin), // new(backgroundm.Group), new(backgroundm.Env), new(backgroundm.Code), new(backgroundm.ApiSource), new(backgroundm.ApiDetail), new(backgroundm.ApiPublic), // new(backgroundm.Template),new(commonm.PropertyNotice), // new(frontm.User), // ) // if beego.AppConfig.String("runmode") == "dev" { // orm.Debug = true // } //} func TableName(name string) string { return beego.AppConfig.String("db.prefix") + name }