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..f70009d4 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(consumer, true); + } + + public QueryWrapper and(Consumer 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 { } public QueryWrapper or(Consumer consumer) { + return or(consumer, true); + } + + public QueryWrapper or(Consumer consumer, boolean condition) { + if (condition) { + return this; + } QueryWrapper newWrapper = new QueryWrapper(); consumer.accept(newWrapper); QueryCondition whereQueryCondition = newWrapper.whereQueryCondition;