init.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**********************************************
  2. ** @Des: This file ...
  3. ** @Author: haodaquan
  4. ** @Date: 2017-09-08 00:18:02
  5. ** @Last Modified by: haodaquan
  6. ** @Last Modified time: 2017-09-16 17:26:48
  7. ***********************************************/
  8. package models
  9. import (
  10. "github.com/astaxie/beego"
  11. _ "github.com/go-sql-driver/mysql"
  12. )
  13. //
  14. //func Init() {
  15. // dbhost := beego.AppConfig.String("db.host")
  16. // dbport := beego.AppConfig.String("db.port")
  17. // dbuser := beego.AppConfig.String("db.user")
  18. // dbpassword := beego.AppConfig.String("db.password")
  19. // dbname := beego.AppConfig.String("db.name")
  20. // timezone := beego.AppConfig.String("db.timezone")
  21. // if dbport == "" {
  22. // dbport = "3306"
  23. // }
  24. // dsn := dbuser + ":" + dbpassword + "@tcp(" + dbhost + ":" + dbport + ")/" + dbname + "?charset=utf8"
  25. // // fmt.Println(dsn)
  26. //
  27. // if timezone != "" {
  28. // dsn = dsn + "&loc=" + url.QueryEscape(timezone)
  29. // }
  30. // orm.RegisterDataBase("default", "mysql", dsn)
  31. // orm.RegisterModel(new(backgroundm.Auth), new(backgroundm.Role), new(backgroundm.RoleAuth), new(backgroundm.Admin),
  32. // new(backgroundm.Group), new(backgroundm.Env), new(backgroundm.Code), new(backgroundm.ApiSource), new(backgroundm.ApiDetail), new(backgroundm.ApiPublic),
  33. // new(backgroundm.Template),new(commonm.PropertyNotice),
  34. // new(frontm.User),
  35. // )
  36. // if beego.AppConfig.String("runmode") == "dev" {
  37. // orm.Debug = true
  38. // }
  39. //}
  40. func TableName(name string) string {
  41. return beego.AppConfig.String("db.prefix") + name
  42. }