From 3c71d4e54bc0454a80c739eb202f4c4d1e804c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jerry=20Zheng=28=E9=84=AD=E5=90=89=E9=8A=B3=29?= Date: Thu, 27 Jul 2023 10:35:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:add=20QueryWrapper=20=E7=9A=84.and()?= =?UTF-8?q?=20.or()=20=E6=96=B9=E6=B3=95,=20=E5=BB=BA=E8=AE=AE=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=80=E4=B8=AA=20boolean=20condition=20=E5=8F=82?= =?UTF-8?q?=E6=95=B0.=20=E7=94=A8=E4=BA=8E=E6=A0=B9=E6=8D=AE=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E6=9D=A1=E4=BB=B6=E6=98=AF=E5=90=A6=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=20consumer.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mybatisflex/core/query/QueryWrapper.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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; From 27e0b0ab33f77c80bda18f780d31bde9c55826fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jerry=20Zheng=28=E9=84=AD=E5=90=89=E9=8A=B3=29?= Date: Thu, 27 Jul 2023 11:23:12 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20Change=20QueryWrapper=20=E7=9A=84.a?= =?UTF-8?q?nd()=20.or()=20=E6=96=B9=E6=B3=95=20boolean=20condition=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E4=BD=8D=E7=BD=AE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mybatisflex/core/query/QueryWrapper.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 cac13fe9..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,10 +224,10 @@ public class QueryWrapper extends BaseQueryWrapper { } public QueryWrapper and(Consumer consumer) { - return and(true, consumer); + return and(consumer, true); } - public QueryWrapper and(boolean condition, Consumer consumer) { + public QueryWrapper and(Consumer consumer, boolean condition) { if (!condition) { return this; } @@ -273,10 +273,10 @@ public class QueryWrapper extends BaseQueryWrapper { } public QueryWrapper or(Consumer consumer) { - return or(true, consumer); + return or(consumer, true); } - public QueryWrapper or(boolean condition, Consumer consumer) { + public QueryWrapper or(Consumer consumer, boolean condition) { if (condition) { return this; }