template_index.js 924 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. /**
  3. * 指标节点业务类
  4. *
  5. * @author Mai
  6. * @date 2018/4/19
  7. * @version
  8. */
  9. module.exports = app => {
  10. class TemplateIndex extends app.BaseService {
  11. /**
  12. * 构造函数
  13. *
  14. * @param {Object} ctx - egg全局context
  15. * @return {void}
  16. */
  17. constructor(ctx) {
  18. super(ctx);
  19. this.tableName = 'template_index';
  20. }
  21. async importData(datas, transaction) {
  22. await transaction.delete(this.tableName, {template_id: 1});
  23. const insertResult = await transaction.insert(this.tableName, datas);
  24. if (insertResult.affectedRows !== datas.length) {
  25. throw '导入指标错误';
  26. }
  27. }
  28. async setRule(data) {
  29. const result = await this.db.update(this.tableName, data);
  30. return result;
  31. }
  32. };
  33. return TemplateIndex;
  34. };