|
@@ -81,6 +81,36 @@ class GoodsService extends CrudService {
|
|
|
const list = await this.goodsModel.aggregate(pipline);
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
+ async indexActTagsGoods() {
|
|
|
+ const dictData = await this.ctx.model.Dev.DictData.find({ code: 'act_tags' });
|
|
|
+ const result = [];
|
|
|
+ for (const t of dictData) {
|
|
|
+ const { label, value } = t;
|
|
|
+ const list = await this.searchActTagsGoods(value);
|
|
|
+ const arr = [];
|
|
|
+ for (const g of list) {
|
|
|
+ const obj = {
|
|
|
+ url: _.get(g, 'file'),
|
|
|
+ name: _.get(g, 'name'),
|
|
|
+ };
|
|
|
+ if (arr.length === 0) {
|
|
|
+ obj.title = label;
|
|
|
+ }
|
|
|
+ arr.push(obj);
|
|
|
+ }
|
|
|
+ result.push({ list: arr });
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ async searchActTagsGoods(act_tags, limit = 2) {
|
|
|
+ const pipline = [{ $match: { status: { $ne: '0' }, act_tags } }];
|
|
|
+ pipline.push({ $project: { name: 1, file: 1 } });
|
|
|
+ if (parseInt(limit)) pipline.push({ $limit: parseInt(limit) });
|
|
|
+ const list = await this.goodsModel.aggregate(pipline);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = GoodsService;
|