table.js 551 B

123456789101112131415161718192021
  1. 'use strict';
  2. const { CrudService } = require('naf-framework-mongoose-free/lib/service');
  3. const template = require('../public/table-template');
  4. class TableService extends CrudService {
  5. constructor(ctx) {
  6. super(ctx, 'table');
  7. this.model = this.ctx.model.Table;
  8. }
  9. async toExport({ ids }) {
  10. const res = await this.model.find({ _id: { $in: ids } });
  11. const data = {};
  12. for (const i of res) {
  13. const d = template(i);
  14. data[i.name_zh ? i.name_zh : i.name] = d;
  15. }
  16. return data;
  17. }
  18. }
  19. module.exports = TableService;