@Override
public PageDTO pageCoupons(UserCouponQuery query) {
Long userId = UserContext.getUser();
userId = 2L;
LambdaQueryWrapper<UserCoupon> queryWrapper = new LambdaQueryWrapper<UserCoupon>().eq(UserCoupon::getUserId, userId);
List<UserCoupon> userCouponList = this.list(queryWrapper);
List<Long> couponIds = userCouponList.stream().map(UserCoupon::getCouponId).distinct().collect(Collectors.toList());
Page<Coupon> couponPage = new Page<>(query.getPageNo(), query.getPageSize());
LambdaQueryWrapper<Coupon> wrapper = new LambdaQueryWrapper<>();
if (CollUtil.isNotEmpty(couponIds)) {
wrapper.in(Coupon::getId, couponIds);
}
Page<Coupon> resultPage = couponMapper.selectPage(couponPage, wrapper);
List<Coupon> records = resultPage.getRecords();
return PageDTO.of(resultPage, records);
}
标签:LambdaQueryWrapper,分页,批量,userId,wrapper,resultPage,mp,query,couponIds From: https://www.cnblogs.com/dragon-proud-sky/p/18321592