Mybatis-Plus 开发技巧
A and (B or C) 问题
使用LambdaQueryWrapper查询时,and和or不能直接拼接,需要用下面这种写法
LambdaQueryWrapper<User> userLambdaQueryWrapper = new LambdaQueryWrapper<User>()
.and(lambda -> lambda
.in(User::getId, userIdSet)
.ge(User::getCreateTime, currentDate)
.or()
.in(User::getId, examineIdSet))
.like(StringUtils.isNotEmpty(name), User::getName, name);
这个LambdaQueryWrapper相当于
select * from user where ((id in xxx and create_time >= xxx) or id in xxx) and name like xxx