diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryWrapper.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryWrapper.java index f88bb204..cac13fe9 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryWrapper.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryWrapper.java @@ -224,6 +224,13 @@ public class QueryWrapper extends BaseQueryWrapper { } public QueryWrapper and(Consumer consumer) { + return and(true, consumer); + } + + public QueryWrapper and(boolean condition, Consumer consumer) { + if (!condition) { + return this; + } QueryWrapper newWrapper = new QueryWrapper(); consumer.accept(newWrapper); QueryCondition whereQueryCondition = newWrapper.whereQueryCondition; @@ -266,6 +273,13 @@ public class QueryWrapper extends BaseQueryWrapper { } public QueryWrapper or(Consumer consumer) { + return or(true, consumer); + } + + public QueryWrapper or(boolean condition, Consumer consumer) { + if (condition) { + return this; + } QueryWrapper newWrapper = new QueryWrapper(); consumer.accept(newWrapper); QueryCondition whereQueryCondition = newWrapper.whereQueryCondition;