3 Star 2 Fork 10

上海老李 / ai_web

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
init.go 2.03 KB
一键复制 编辑 原始数据 按行查看 历史
上海老李 提交于 2019-05-24 12:31 . 初始化
/**********************************************
** @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 (
//"net/url"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
//_ "github.com/go-sql-driver/mysql"
"github.com/astaxie/beego/logs"
_ "github.com/lib/pq"
)
func Init() {
////mysql db server param
//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)
//}
//postgres_sql dbstr
pgstr := beego.AppConfig.String("dbstring")
orm.RegisterDataBase("default", "postgres", pgstr)
orm.RegisterModel(new(Auth), new(Role), new(RoleAuth), new(Admin), new(AiCdr), new(AiFlowContent),
new(Group), new(Env), new(Code), new(Api), new(ApiDetail), new(AiProcess), new(RunTimeModel),
new(AiProcessContent), new(ApiParam), new(AiTpl), new(AiTask), new(AiNumbers), new(AIVoiceLibrary),
new(NumberGroup), new(NumberGroupMap), new(AiNotMatch), new(GroupMap), new(AiServers), new(GateWay),
new(GatewayGroup), new(AiExtansion), new(AiSeatGroup), new(AiSeatTask), new(AiSeatGroupMap), new(AiSeat),
new(AiRoute), new(AiRouteDetails))
if beego.AppConfig.String("runmode") == "dev" {
orm.Debug = true
}
//配置日志
logs.SetLogger(logs.AdapterFile, `{"filename":"`+beego.AppConfig.String("log_file")+`"}`)
}
func TableName(name string) string {
return beego.AppConfig.String("db.prefix") + name
}
func ErrorLog(err error) {
logs.Error(err)
}
func Eqint64(a, b int64) bool {
return a == b
}
1
https://gitee.com/nwaycn/ai_web.git
git@gitee.com:nwaycn/ai_web.git
nwaycn
ai_web
ai_web
205a314fbb28

搜索帮助