|
@@ -12,6 +12,7 @@ class IndexService extends CrudService {
|
|
|
constructor(ctx) {
|
|
|
super(ctx, 'index');
|
|
|
this.model = this.ctx.model.Dock;
|
|
|
+ this.dockUser = this.ctx.model.DockUser;
|
|
|
}
|
|
|
async create(body) {
|
|
|
const last = await this.model.findOne().sort({ room_id: -1 });
|
|
@@ -74,6 +75,19 @@ class IndexService extends CrudService {
|
|
|
const token = jwt.sign(data, jwts);
|
|
|
return token;
|
|
|
}
|
|
|
+
|
|
|
+ async dockProduct({ dock_id, type, skip = 0, limit = 10 } = {}) {
|
|
|
+ assert(dock_id, '缺少展会信息');
|
|
|
+ assert(type, '要查询的类型');
|
|
|
+ const res = await this.dockUser.aggregate([
|
|
|
+ { $match: { dock_id: ObjectId(dock_id), 'goodsList.type': type } },
|
|
|
+ { $project: { goodsList: 1 } },
|
|
|
+ { $unwind: '$goodsList' },
|
|
|
+ { $match: { 'goodsList.status': '1' } },
|
|
|
+ ]);
|
|
|
+ const list = res.map(i => i.goodsList);
|
|
|
+ return { data: _.slice(list, skip, skip + limit), total: list.length };
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = IndexService;
|