'use strict'; const { CrudService } = require('naf-framework-mongoose-free/lib/service'); const { BusinessError, ErrorCode } = require('naf-core').Error; const _ = require('lodash'); const assert = require('assert'); // class BillService extends CrudService { constructor(ctx) { super(ctx, 'bill'); this.model = this.ctx.model.Race.Bill; this.baseUserModel = this.ctx.model.Base.User; } async afterQuery(filter, data) { for (const i of data) { const user_id = _.get(i, 'payer_id.user_id'); const user = await this.baseUserModel.findById(user_id); if (user) i.payer_name = user.name; } return data; } } module.exports = BillService;