|
@@ -103,22 +103,13 @@ class GoodsService extends CrudService {
|
|
sort: '$data.sort',
|
|
sort: '$data.sort',
|
|
},
|
|
},
|
|
});
|
|
});
|
|
- sort.sort = 1;
|
|
|
|
- sort = { ...sort, sort: 1, create_time: -1 };
|
|
|
|
|
|
+ if (Object.keys(sort).length <= 0) sort = { sort: -1, create_time: -1 };
|
|
pipline.push({ $sort: sort });
|
|
pipline.push({ $sort: sort });
|
|
// 分页处理
|
|
// 分页处理
|
|
const qPipline = _.cloneDeep(pipline);
|
|
const qPipline = _.cloneDeep(pipline);
|
|
if (parseInt(skip)) qPipline.push({ $skip: parseInt(skip) });
|
|
if (parseInt(skip)) qPipline.push({ $skip: parseInt(skip) });
|
|
if (parseInt(limit)) qPipline.push({ $limit: parseInt(limit) });
|
|
if (parseInt(limit)) qPipline.push({ $limit: parseInt(limit) });
|
|
- let list = await this.goodsModel.aggregate(qPipline);
|
|
|
|
- // 处理合并图片
|
|
|
|
- list = list.map(i => {
|
|
|
|
- if (_.isArray(i.spec_file)) {
|
|
|
|
- i.file = [ ...i.spec_file, ...i.file ];
|
|
|
|
- delete i.spec_file;
|
|
|
|
- }
|
|
|
|
- return i;
|
|
|
|
- });
|
|
|
|
|
|
+ const list = await this.goodsModel.aggregate(qPipline);
|
|
const tPipline = _.cloneDeep(pipline);
|
|
const tPipline = _.cloneDeep(pipline);
|
|
tPipline.push({ $count: 'total' });
|
|
tPipline.push({ $count: 'total' });
|
|
const total = await this.goodsModel.aggregate(tPipline);
|
|
const total = await this.goodsModel.aggregate(tPipline);
|