dockTranscation.js 878 B

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. const { CrudService } = require('naf-framework-mongoose-free/lib/service');
  3. const { BusinessError, ErrorCode } = require('naf-core').Error;
  4. const _ = require('lodash');
  5. const assert = require('assert');
  6. // 展会合同备份
  7. class DockTranscationService extends CrudService {
  8. constructor(ctx) {
  9. super(ctx, 'dock_transcation');
  10. this.model = this.ctx.model.Dock.DockTranscation;
  11. }
  12. /**
  13. * 查该用户的供/需记录
  14. * @param {Object} Object
  15. */
  16. async getUserList({ skip = 0, limit = 0, ...query } = {}) {
  17. const { user_id, ...info } = query;
  18. const nquery = { ...info, $or: [{ s_id: user_id }, { d_id: user_id }] };
  19. const data = await this.model.find(nquery).skip(parseInt(skip)).limit(parseInt(limit));
  20. const total = await this.model.count(nquery);
  21. return { data, total };
  22. }
  23. }
  24. module.exports = DockTranscationService;