123456789101112131415161718192021222324252627282930313233343536373839 |
- 'use strict';
- /**
- * 指标节点业务类
- *
- * @author Mai
- * @date 2018/4/19
- * @version
- */
- module.exports = app => {
- class TemplateIndex extends app.BaseService {
- /**
- * 构造函数
- *
- * @param {Object} ctx - egg全局context
- * @return {void}
- */
- constructor(ctx) {
- super(ctx);
- this.tableName = 'template_index';
- }
- async importData(datas, transaction) {
- await transaction.delete(this.tableName, {template_id: 1});
- const insertResult = await transaction.insert(this.tableName, datas);
- if (insertResult.affectedRows !== datas.length) {
- throw '导入指标错误';
- }
- }
- async setRule(data) {
- const result = await this.db.update(this.tableName, data);
- return result;
- }
- };
- return TemplateIndex;
- };
|