//1.分组查询
Aggregation agg=Aggregation.newAggregation(
Aggregation.match(Criteria.where("tenantId").is(TenantUtils.getTenantId()).and("ancestor._id").is(id).and("vmallOnShelf").is(true)),
Aggregation.group("goodsId").push(Aggregation.ROOT).as("goodsList").first("vmallPrice").as("vmallPrice"),
Aggregation.sort(direction, "vmallPrice"),
Aggregation.skip(m),
Aggregation.limit(n)
);
List<GoodsSKU> list = mongoTemplate.aggregate(agg,"goods", GoodsSKU.class).getMappedResults();
return list.stream().map(GoodsSKU::getFirstGoods).collect(Collectors.toList());
mongo基本操作
最新推荐文章于 2022-10-14 01:12:14 发布
