template_index.js 896 B

12345678910111213141516171819202122232425262728293031323334353637
  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. console.log(datas[241]);
  23. console.log(datas[242]);
  24. console.log(datas[243]);
  25. await transaction.delete(this.tableName, {template_id: 1});
  26. const insertResult = await transaction.insert(this.tableName, datas);
  27. if (insertResult.affectedRows !== datas.length) {
  28. throw '导入指标错误';
  29. }
  30. }
  31. };
  32. return TemplateIndex;
  33. };