order.js 586 B

123456789101112131415161718192021
  1. 'use strict';
  2. const { CrudService } = require('naf-framework-mongoose-free/lib/service');
  3. const _ = require('lodash');
  4. // 订单表
  5. class OrderService extends CrudService {
  6. constructor(ctx) {
  7. super(ctx, 'order');
  8. this.model = this.ctx.model.Order;
  9. this.tableModel = this.ctx.model.Table;
  10. }
  11. async getOrder({ id }) {
  12. const table_id = _.get(this.ctx, 'table');
  13. const order = await this.model.fetch(id);
  14. const table_num = await this.tableModel.fetch(table_id);
  15. const obj = { ...order, ...table_num };
  16. return obj;
  17. }
  18. }
  19. module.exports = OrderService;