|
@@ -3,6 +3,7 @@ const { CrudService } = require('naf-framework-mongoose-free/lib/service');
|
|
|
const { BusinessError, ErrorCode } = require('naf-core').Error;
|
|
|
const _ = require('lodash');
|
|
|
const assert = require('assert');
|
|
|
+const { ObjectId } = require('mongoose').Types;
|
|
|
|
|
|
//
|
|
|
class GoodsService extends CrudService {
|
|
@@ -38,12 +39,13 @@ class GoodsService extends CrudService {
|
|
|
async indexGoodsList(condition, { skip = 0, limit = 20 } = {}) {
|
|
|
condition = this.dealFilter(condition);
|
|
|
const pipline = [{ $match: { status: { $ne: '0' } } }];
|
|
|
- const { view_num, sell_num, sell_money, name } = condition;
|
|
|
+ const { view_num, sell_num, sell_money, name, shop } = condition;
|
|
|
const sort = {};
|
|
|
if (view_num) sort.view_num = view_num;
|
|
|
if (sell_num) sort.sell_num = sell_num;
|
|
|
if (sell_money) sort.sell_money = sell_money;
|
|
|
if (name) pipline.push({ $match: { name } });
|
|
|
+ if (shop) pipline.push({ $match: { shop } });
|
|
|
|
|
|
pipline.push({ $addFields: { goods_id: { $toString: '$_id' } } });
|
|
|
// 表关联
|
|
@@ -76,6 +78,7 @@ class GoodsService extends CrudService {
|
|
|
// 分页处理
|
|
|
if (parseInt(skip)) pipline.push({ $skip: parseInt(skip) });
|
|
|
if (parseInt(limit)) pipline.push({ $limit: parseInt(limit) });
|
|
|
+ console.log(pipline);
|
|
|
const list = await this.goodsModel.aggregate(pipline);
|
|
|
return list;
|
|
|
}
|