mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 17:18:24 +08:00
!194 feat:add QueryWrapper .and(Consumer consumer) .or(Consumer consumer) 方法, 增加一个 boolean condition 参数. 用于根据动态条件是否执行 consumer.
Merge pull request !194 from Jerry_Zheng/main
This commit is contained in:
commit
a082dcc553
@ -224,6 +224,13 @@ public class QueryWrapper extends BaseQueryWrapper<QueryWrapper> {
|
||||
}
|
||||
|
||||
public QueryWrapper and(Consumer<QueryWrapper> consumer) {
|
||||
return and(consumer, true);
|
||||
}
|
||||
|
||||
public QueryWrapper and(Consumer<QueryWrapper> consumer, boolean condition) {
|
||||
if (!condition) {
|
||||
return this;
|
||||
}
|
||||
QueryWrapper newWrapper = new QueryWrapper();
|
||||
consumer.accept(newWrapper);
|
||||
QueryCondition whereQueryCondition = newWrapper.whereQueryCondition;
|
||||
@ -266,6 +273,13 @@ public class QueryWrapper extends BaseQueryWrapper<QueryWrapper> {
|
||||
}
|
||||
|
||||
public QueryWrapper or(Consumer<QueryWrapper> consumer) {
|
||||
return or(consumer, true);
|
||||
}
|
||||
|
||||
public QueryWrapper or(Consumer<QueryWrapper> consumer, boolean condition) {
|
||||
if (condition) {
|
||||
return this;
|
||||
}
|
||||
QueryWrapper newWrapper = new QueryWrapper();
|
||||
consumer.accept(newWrapper);
|
||||
QueryCondition whereQueryCondition = newWrapper.whereQueryCondition;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user