init.go
547 字节
package bgorm
import (
"fmt"
"github.com/astaxie/beego/orm"
_ "github.com/go-sql-driver/mysql"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"openapi/pkg/constant"
_ "openapi/pkg/infrastructure/bgorm/model"
)
func init() {
aliasName := "default"
if err := orm.RegisterDataBase(aliasName, "mysql", constant.MYSQL_DATA_SOURCE); err != nil {
log.Error(fmt.Sprintf("【MYSQL】注册数据库失败:%v", err))
return
}
orm.SetMaxIdleConns(aliasName, constant.MYSQL_MAX_IDLE)
orm.SetMaxOpenConns(aliasName, constant.MYSQL_MAX_OPEN)
}