investigation.js 918 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. const { CrudService } = require('naf-framework-mongoose/lib/service');
  3. const { BusinessError, ErrorCode } = require('naf-core').Error;
  4. const _ = require('lodash');
  5. const assert = require('assert');
  6. // 企业需求
  7. class InvestigationService extends CrudService {
  8. constructor(ctx) {
  9. super(ctx, 'investigation');
  10. this.model = this.ctx.model.Investigation;
  11. }
  12. async query(filter, options = {}) {
  13. const { filter: nf, options: no } = this.ctx.service.util.util.dealQuery(_.cloneDeep(filter), _.cloneDeep(options));
  14. const { skip, limit, sort, projection } = no;
  15. const rs = await this.model.find(nf, projection, { skip, limit, sort }).exec();
  16. return rs;
  17. }
  18. async count(filter) {
  19. const nf = this.ctx.service.util.util.dealFilter(_.cloneDeep(filter));
  20. const res = await this.model.countDocuments(nf).exec();
  21. return res;
  22. }
  23. }
  24. module.exports = InvestigationService;