'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 PlatformActService extends CrudService { constructor(ctx) { super(ctx, 'platformact'); this.model = this.ctx.model.System.PlatformAct; } async query(filter, { skip = 0, limit, projection } = {}) { let condition = _.cloneDeep(filter); condition = await this.beforeQuery(condition); condition = this.dealFilter(condition); // 过滤出ref字段 const { populate } = this.getRefMods(); // 带ref查询 let rs = await this.model.find(condition, projection, { skip, limit, sort: { sort: 1, 'meta.createdAt': -1 } }).populate(populate).exec(); rs = JSON.parse(JSON.stringify(rs)); // 整理ref数据 rs = await this.afterQuery(filter, rs); return rs; } } module.exports = PlatformActService;