作者 yangfu

1.修改环境变量

@@ -11,8 +11,8 @@ AccessKeySecret ="aLZXwK8pgrs10Ws03qcN7NsrSXFVsg" @@ -11,8 +11,8 @@ AccessKeySecret ="aLZXwK8pgrs10Ws03qcN7NsrSXFVsg"
11 cname ="https://media.fjmaimaimai.com/" 11 cname ="https://media.fjmaimaimai.com/"
12 12
13 #数据库相关 13 #数据库相关
14 -MYSQL_USER = "${MYSQL_USER||root}"  
15 -MYSQL_PASSWORD = "${MYSQL_PASSWORD||sutianxia2018}"  
16 -MYSQL_HOST = "${MYSQL_HOST||101.37.68.23}"  
17 -MYSQL_PORT = "${MYSQL_PORT||3306}"  
18 -MYSQL_DB_NAME = "${MYSQL_DB_NAME||mmm_open_test}"  
  14 +MYSQL_USER = "${MYSQL_USER||root1}"
  15 +MYSQL_PASSWORD = "${MYSQL_PASSWORD||sutianxia20181}"
  16 +MYSQL_HOST = "${MYSQL_HOST||101.37.68.231}"
  17 +MYSQL_PORT = "${MYSQL_PORT||33061}"
  18 +MYSQL_DB_NAME = "${MYSQL_DB_NAME||mmm_open_test1}"
@@ -79,6 +79,8 @@ spec: @@ -79,6 +79,8 @@ spec:
79 configMapKeyRef: 79 configMapKeyRef:
80 name: suplus-config 80 name: suplus-config
81 key: mysql.password 81 key: mysql.password
  82 + - name: MYSQL_DB_NAME
  83 + value: "mmm_open_test"
82 - name: RUN_MODE 84 - name: RUN_MODE
83 value: "test" 85 value: "test"
84 - name: LOG_LEVEL 86 - name: LOG_LEVEL
1 package bgorm 1 package bgorm
2 2
3 import ( 3 import (
  4 + "fmt"
4 "github.com/astaxie/beego/orm" 5 "github.com/astaxie/beego/orm"
5 _ "github.com/go-sql-driver/mysql" 6 _ "github.com/go-sql-driver/mysql"
6 "openapi/pkg/constant" 7 "openapi/pkg/constant"
7 _ "openapi/pkg/infrastructure/bgorm/model" 8 _ "openapi/pkg/infrastructure/bgorm/model"
  9 + "openapi/pkg/infrastructure/log"
8 ) 10 )
9 11
10 func init() { 12 func init() {
11 aliasName := "default" 13 aliasName := "default"
12 - _ = orm.RegisterDataBase(aliasName, "mysql", constant.MYSQL_DATA_SOURCE) 14 + if err := orm.RegisterDataBase(aliasName, "mysql", constant.MYSQL_DATA_SOURCE); err != nil {
  15 + log.Error(fmt.Sprintf("【MYSQL】注册数据库失败:%v source:%v", err, constant.MYSQL_DATA_SOURCE))
  16 + return
  17 + }
13 orm.SetMaxIdleConns(aliasName, constant.MYSQL_MAX_IDLE) 18 orm.SetMaxIdleConns(aliasName, constant.MYSQL_MAX_IDLE)
14 orm.SetMaxOpenConns(aliasName, constant.MYSQL_MAX_OPEN) 19 orm.SetMaxOpenConns(aliasName, constant.MYSQL_MAX_OPEN)
15 } 20 }