|
@@ -35,6 +35,7 @@ class TreeService extends Service {
|
|
super(ctx);
|
|
super(ctx);
|
|
this.tableName = setting.tableName;
|
|
this.tableName = setting.tableName;
|
|
this.setting = setting;
|
|
this.setting = setting;
|
|
|
|
+ if (this.setting.cacheKey === undefined) this.setting.cacheKey = true;
|
|
// 以下字段仅可通过树结构操作改变,不可直接通过update方式从接口提交,发现时过滤
|
|
// 以下字段仅可通过树结构操作改变,不可直接通过update方式从接口提交,发现时过滤
|
|
this.readOnlyFields = ['id'];
|
|
this.readOnlyFields = ['id'];
|
|
this.readOnlyFields.push(this.setting.mid);
|
|
this.readOnlyFields.push(this.setting.mid);
|
|
@@ -332,19 +333,13 @@ class TreeService extends Service {
|
|
*/
|
|
*/
|
|
async _getMaxLid(mid) {
|
|
async _getMaxLid(mid) {
|
|
const cacheKey = this.setting.keyPre + mid;
|
|
const cacheKey = this.setting.keyPre + mid;
|
|
- let maxId = parseInt(await this.cache.get(cacheKey));
|
|
|
|
- // 判断是否存在变更新增部位maxId,有则取两者最大值
|
|
|
|
- const changeReviseCacheKey = 'change_ledger_maxLid2:' + mid;
|
|
|
|
- const changeReviseMaxId = await this.cache.get(changeReviseCacheKey);
|
|
|
|
- if (changeReviseMaxId) {
|
|
|
|
- maxId = !maxId ? parseInt(changeReviseMaxId) : Math.max(maxId, parseInt(changeReviseMaxId));
|
|
|
|
- }
|
|
|
|
|
|
+ let maxId = this.setting.cacheKey ? parseInt(await this.cache.get(cacheKey)) : undefined;
|
|
if (!maxId) {
|
|
if (!maxId) {
|
|
const sql = 'SELECT Max(??) As max_id FROM ?? Where ' + this.setting.mid + ' = ?';
|
|
const sql = 'SELECT Max(??) As max_id FROM ?? Where ' + this.setting.mid + ' = ?';
|
|
const sqlParam = [this.setting.kid, this.tableName, mid];
|
|
const sqlParam = [this.setting.kid, this.tableName, mid];
|
|
const queryResult = await this.db.queryOne(sql, sqlParam);
|
|
const queryResult = await this.db.queryOne(sql, sqlParam);
|
|
maxId = queryResult.max_id || 0;
|
|
maxId = queryResult.max_id || 0;
|
|
- this.cache.set(cacheKey, maxId, 'EX', this.ctx.app.config.cacheTime);
|
|
|
|
|
|
+ if (this.setting.cacheKey) this.cache.set(cacheKey, maxId, 'EX', this.ctx.app.config.cacheTime);
|
|
}
|
|
}
|
|
return maxId;
|
|
return maxId;
|
|
}
|
|
}
|