|
@@ -10,6 +10,30 @@ class GoodsSpecService extends CrudService {
|
|
super(ctx, 'goodsspec');
|
|
super(ctx, 'goodsspec');
|
|
this.model = this.ctx.model.Shop.GoodsSpec;
|
|
this.model = this.ctx.model.Shop.GoodsSpec;
|
|
}
|
|
}
|
|
|
|
+ async query(filter, { skip = 0, limit, sort, projection } = {}) {
|
|
|
|
+ const { sort: fs } = filter;
|
|
|
|
+ console.log(fs);
|
|
|
|
+ if (fs) {
|
|
|
|
+ sort.sort = parseInt(fs);
|
|
|
|
+ delete filter.sort;
|
|
|
|
+ }
|
|
|
|
+ // 处理排序
|
|
|
|
+ // if (sort && _.isString(sort)) {
|
|
|
|
+ // sort = { [sort]: desc ? -1 : 1 };
|
|
|
|
+ // } else if (sort && _.isArray(sort)) {
|
|
|
|
+ // sort = sort.map(f => ({ [f]: desc ? -1 : 1 })).reduce((p, c) => ({ ...p, ...c }), {});
|
|
|
|
+ // }
|
|
|
|
+ let condition = _.cloneDeep(filter);
|
|
|
|
+ condition = await this.beforeQuery(condition);
|
|
|
|
+ condition = this.dealFilter(condition);
|
|
|
|
+ // 过滤出ref字段
|
|
|
|
+ const { refMods, populate } = this.getRefMods();
|
|
|
|
+ // 带ref查询
|
|
|
|
+ let rs = await this.model.find(condition, projection, { skip, limit, sort }).populate(populate).exec();
|
|
|
|
+ rs = JSON.parse(JSON.stringify(rs));
|
|
|
|
+ rs = await this.afterQuery(filter, rs);
|
|
|
|
+ return rs;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
module.exports = GoodsSpecService;
|
|
module.exports = GoodsSpecService;
|