table.js 674 B

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