...
|
...
|
@@ -2,12 +2,14 @@ const mysql = require('mysql'); |
|
|
const _ = require('lodash');
|
|
|
const md5 = require('yoho-md5');
|
|
|
const qs = require('querystring');
|
|
|
const monitorType = 'sql';
|
|
|
|
|
|
class SqlHelper {
|
|
|
constructor(database) {
|
|
|
this.config = global.yoho.config.mysql;
|
|
|
this.logger = global.yoho.logger;
|
|
|
this.cache = global.yoho.cache;
|
|
|
this.monitor = global.yoho.monitorSender;
|
|
|
database = database || 'mysql';
|
|
|
this.createPool(database);
|
|
|
}
|
...
|
...
|
@@ -95,10 +97,12 @@ class SqlHelper { |
|
|
// 写入缓存
|
|
|
cacheTime && this.cache.set(cacheKey, result, cacheTime);
|
|
|
resolve(result);
|
|
|
this.monitor && this.monitor.tallySuccess(monitorType);
|
|
|
}
|
|
|
});
|
|
|
}).catch(e => {
|
|
|
reject(e);
|
|
|
reject(e);
|
|
|
this.monitor && this.monitor.tallyFail(monitorType, e);
|
|
|
});
|
|
|
});
|
|
|
}
|
...
|
...
|
|