'use strict'; const { CrudService } = require('naf-framework-mongoose/lib/service'); const { BusinessError, ErrorCode } = require('naf-core').Error; const _ = require('lodash'); const assert = require('assert'); // 企业需求 class InvestigationService extends CrudService { constructor(ctx) { super(ctx, 'investigation'); this.model = this.ctx.model.Investigation; } async query(filter, options = {}) { const { filter: nf, options: no } = this.ctx.service.util.util.dealQuery(_.cloneDeep(filter), _.cloneDeep(options)); const { skip, limit, sort, projection } = no; const rs = await this.model.find(nf, projection, { skip, limit, sort }).exec(); return rs; } async count(filter) { const nf = this.ctx.service.util.util.dealFilter(_.cloneDeep(filter)); const res = await this.model.countDocuments(nf).exec(); return res; } } module.exports = InvestigationService;