template_param.js 769 B

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date 2018/4/23
  7. * @version
  8. */
  9. module.exports = app => {
  10. class TemplateParam 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_param';
  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. };
  29. return TemplateParam;
  30. };