This commit is contained in:
aozhiwei 2023-07-11 18:03:04 +08:00
parent b0a256e418
commit bfee2f5bcf

View File

@ -158,38 +158,23 @@ class BaseEventProcess {
}
async bcEventDbConn(method, ...args) {
if (!this.bcEventConn) {
const {err, conn} = await app.getDbConn(constant.BCEVENTDB_NAME);
if (err) {
return {
'err': err,
'row': null,
'rows': null
};
}
this.bcEventConn = conn;
}
return await this.internalDbConn(this.bcEventConn, method, ...args);
const conn = await this.recreateConn('bcEventConn', constant.BCEVENTDB_NAME);
return await this.internalDbConn(conn, method, ...args);
}
async bcNftDbConn(method, ...args) {
if (!this.bcNftConn) {
const {err, conn} = await app.getDbConn(constant.BCNFTDB_NAME);
if (err) {
return {
'err': err,
'row': null,
'rows': null
};
}
this.bcNftConn = conn;
}
return await this.internalDbConn(this.bcNftConn, method, ...args);
const conn = await this.recreateConn('bcNftConn', constant.BCNFTDB_NAME);
return await this.internalDbConn(conn, method, ...args);
}
async gameDbConn(method, ...args) {
if (!this.gameConn) {
const {err, conn} = await app.getDbConn(constant.GAMEDB_NAME);
const conn = await this.recreateConn('gameConn', constant.GAMEDB_NAME);
return await this.internalDbConn(conn, method, ...args);
}
async recreateConn(connName, dbName) {
if (!this[connName]) {
const {err, conn} = await app.getDbConn(dbName);
if (err) {
return {
'err': err,
@ -197,9 +182,9 @@ class BaseEventProcess {
'rows': null
};
}
this.gameConn = conn;
this[connName] = conn;
}
return await this.internalDbConn(this.gameConn, method, ...args);
return this[connName];
}
async internalDbConn(conn, method, ...args) {