|
@@ -41,6 +41,9 @@ var writeSgjPatientDb *gorm.DB
|
41
|
41
|
var readUserDbT *gorm.DB
|
42
|
42
|
var writeUserDbT *gorm.DB
|
43
|
43
|
|
|
44
|
+var readSwsDb *gorm.DB
|
|
45
|
+var writeSwsDb *gorm.DB
|
|
46
|
+
|
44
|
47
|
var err error
|
45
|
48
|
|
46
|
49
|
func ConnectDB() {
|
|
@@ -116,6 +119,18 @@ func ConnectDB() {
|
116
|
119
|
writeUserPassT := beego.AppConfig.String("writeuserpassTest")
|
117
|
120
|
writeUserNameT := beego.AppConfig.String("writeusernameTest")
|
118
|
121
|
|
|
122
|
+ readSwsHost := beego.AppConfig.String("readswshost")
|
|
123
|
+ readSwsPort := beego.AppConfig.String("readswsport")
|
|
124
|
+ readSwsUser := beego.AppConfig.String("readswsuser")
|
|
125
|
+ readSwsPass := beego.AppConfig.String("readswspass")
|
|
126
|
+ readSwsName := beego.AppConfig.String("readswsname")
|
|
127
|
+
|
|
128
|
+ writeSwsHost := beego.AppConfig.String("writeswshost")
|
|
129
|
+ writeSwsPort := beego.AppConfig.String("writeswsport")
|
|
130
|
+ writeSwsUser := beego.AppConfig.String("writeswsuser")
|
|
131
|
+ writeSwsPass := beego.AppConfig.String("writeswspass")
|
|
132
|
+ writeSwsName := beego.AppConfig.String("writeswsname")
|
|
133
|
+
|
119
|
134
|
rdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUser, readPass, readHost, readPort, readName)
|
120
|
135
|
wdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUser, writePass, writeHost, writePort, writeName)
|
121
|
136
|
|
|
@@ -134,7 +149,11 @@ func ConnectDB() {
|
134
|
149
|
rudsnT := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUserUserT, readUserPassT, readUserHostT, readUserPortT, readUserNameT)
|
135
|
150
|
wudsnT := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUserUserT, writeUserPassT, writeUserHostT, writeUserPortT, writeUserNameT)
|
136
|
151
|
|
|
152
|
+ rsdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readSwsUser, readSwsPass, readSwsHost, readSwsPort, readSwsName)
|
|
153
|
+ wsdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeSwsUser, writeSwsPass, writeSwsHost, writeSwsPort, writeSwsName)
|
|
154
|
+
|
137
|
155
|
readDb, err = gorm.Open("mysql", rdsn)
|
|
156
|
+
|
138
|
157
|
if err != nil {
|
139
|
158
|
//beego.Error(err)
|
140
|
159
|
}
|
|
@@ -229,6 +248,22 @@ func ConnectDB() {
|
229
|
248
|
writeSgjPatientDb.DB().SetMaxIdleConns(10)
|
230
|
249
|
writeSgjPatientDb.DB().SetMaxOpenConns(100)
|
231
|
250
|
writeSgjPatientDb.LogMode(true)
|
|
251
|
+
|
|
252
|
+ readSwsDb, err = gorm.Open("mysql", rsdsn)
|
|
253
|
+ if err != nil {
|
|
254
|
+ //beego.Error(err)
|
|
255
|
+ }
|
|
256
|
+ readSwsDb.DB().SetMaxIdleConns(10)
|
|
257
|
+ readSwsDb.DB().SetMaxOpenConns(100)
|
|
258
|
+ readSwsDb.LogMode(true)
|
|
259
|
+
|
|
260
|
+ writeSwsDb, err = gorm.Open("mysql", wsdsn)
|
|
261
|
+ if err != nil {
|
|
262
|
+ //beego.Error(err)
|
|
263
|
+ }
|
|
264
|
+ writeSwsDb.DB().SetMaxIdleConns(10)
|
|
265
|
+ writeSwsDb.DB().SetMaxOpenConns(100)
|
|
266
|
+ writeSwsDb.LogMode(true)
|
232
|
267
|
}
|
233
|
268
|
|
234
|
269
|
//func DisconnectDB() {
|