mybatisPlus的lambdaQueryWrapper的模糊和or和排序分页查询

后端 0 186
知识社区小编
知识社区小编 2021年12月5日 16:45 发表
摘要:mybatisPlus的lambdaQueryWrapper的模糊和or和排序分页查询


LambdaQueryWrapper<StoreConsumer> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(StoreConsumer::getStoreId, req.getStoreId());


if (req.getName() != null) {
lambdaQueryWrapper.like(StoreConsumer::getName, req.getName());
}
if (req.getMobile() != null) {
lambdaQueryWrapper.like(StoreConsumer::getMobile, req.getMobile());
}
if (req.getPayCount() != null) {
lambdaQueryWrapper.eq(StoreConsumer::getPayCount, req.getPayCount());
}
if (req.getIntegral() != null) {
lambdaQueryWrapper.eq(StoreConsumer::getIntegral, req.getIntegral());
}

if (Objects.nonNull(req.getStartRegisterTime())) {
lambdaQueryWrapper.apply((ObjectUtil.isNotNull(req.getStartRegisterTime())), "DATE_FORMAT(created, '%Y-%m-%d') >= {0}", req.getStartRegisterTime());
}
if (Objects.nonNull(req.getEndRegisterTime())) {
lambdaQueryWrapper.apply((ObjectUtil.isNotNull(req.getEndRegisterTime())), "DATE_FORMAT(created, '%Y-%m-%d') <= {0}", req.getEndRegisterTime());
}

if (req.getOrigin() != null) {
lambdaQueryWrapper.eq(StoreConsumer::getOrigin, req.getOrigin());
}

if (req.getTagId() != null) {
//查询标签表
StoreConsumerTag s = storeConsumerTagMapper.selectById(req.getTagId());
lambdaQueryWrapper.and(
wrapper -> wrapper
.ge(StoreConsumer::getSuccessOrder, s.getSuccessOrder())
.or()
.ge(StoreConsumer::getPayCount, s.getPayCount())
.or()
.ge(StoreConsumer::getPayMoney, s.getPayMoney())
.or()
.ge(StoreConsumer::getIntegral, s.getIntegral())
);
}

lambdaQueryWrapper.orderByDesc(StoreConsumer::getRegisterTime);


点赞 0 收藏(0)    分享
相关标签: 分页 模糊 排序
0 个评论
  • 消灭零评论