lrf %!s(int64=2) %!d(string=hai) anos
pai
achega
8dac24bd89
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      app/service/view/goods.js

+ 2 - 1
app/service/view/goods.js

@@ -39,13 +39,14 @@ class GoodsService extends CrudService {
   async indexGoodsList(condition, { skip = 0, limit = 20 } = {}) {
     condition = this.dealFilter(condition);
     const pipline = [{ $sort: { 'meta.createdAt': -1 } }, { $match: { status: { $ne: '0' } } }];
-    const { view_num, sell_num, sell_money, name, shop } = condition;
+    const { view_num, sell_num, sell_money, name, shop, tags } = 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: new RegExp(name) } });
     if (shop) pipline.push({ $match: { shop } });
+    if (tags) pipline.push({ tags: { $elemMatch: { $elemMatch: { $eq: tags } } } });
 
     pipline.push({ $addFields: { goods_id: { $toString: '$_id' } } });
     // 表关联