std_extra_list.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date 2023/7/3
  7. * @version
  8. */
  9. module.exports = app => {
  10. class StdExtraList extends app.BaseService {
  11. /**
  12. * 构造函数
  13. *
  14. * @param {Object} ctx - egg全局变量
  15. * @return {void}
  16. */
  17. constructor(ctx) {
  18. super(ctx);
  19. this.tableName = 'std_extra_list';
  20. }
  21. async getList(subType) {
  22. return await this.getAllDataByCondition({ columns: ['id', 'name'], where: { sub_type: subType } });
  23. }
  24. async getSpecList() {
  25. const result = await this.getAllDataByCondition({ columns: ['id', 'name'], where: { sub_type: 0 } });
  26. for (const r of result) {
  27. const detail = await this.ctx.service.stdExtra.getAllDataByCondition({ columns: ['spec', 'value'], where: { list_id: r.id }, orders:[['order', 'asc']]});
  28. r.spec = detail.map(x => { return x.spec });
  29. r.value = detail.map(x => { return x.value });
  30. }
  31. return result;
  32. }
  33. }
  34. return StdExtraList;
  35. };