From e9a6f36136319d65ba6379506264c94a4994d269 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Sun, 21 Sep 2025 19:13:20 +0800 Subject: [PATCH] =?UTF-8?q?refactor(data):=20=E7=A7=BB=E9=99=A4=20QueryIgn?= =?UTF-8?q?ore=20=E6=B3=A8=E8=A7=A3=EF=BC=8C=E5=B9=B6=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=20eq=20=E9=80=BB=E8=BE=91=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../starter/data/annotation/QueryIgnore.java | 30 ------------------- .../starter/data/util/QueryWrapperHelper.java | 12 ++------ .../starter/data/util/QueryWrapperHelper.java | 12 ++------ 3 files changed, 6 insertions(+), 48 deletions(-) delete mode 100644 continew-starter-data/continew-starter-data-core/src/main/java/top/continew/starter/data/annotation/QueryIgnore.java diff --git a/continew-starter-data/continew-starter-data-core/src/main/java/top/continew/starter/data/annotation/QueryIgnore.java b/continew-starter-data/continew-starter-data-core/src/main/java/top/continew/starter/data/annotation/QueryIgnore.java deleted file mode 100644 index d14638f0..00000000 --- a/continew-starter-data/continew-starter-data-core/src/main/java/top/continew/starter/data/annotation/QueryIgnore.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. - *

- * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.gnu.org/licenses/lgpl.html - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package top.continew.starter.data.annotation; - -import java.lang.annotation.*; - -/** - * 查询解析忽略注解 - * - * @author Charles7c - * @since 1.3.0 - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface QueryIgnore {} diff --git a/continew-starter-data/continew-starter-data-mf/src/main/java/top/continew/starter/data/util/QueryWrapperHelper.java b/continew-starter-data/continew-starter-data-mf/src/main/java/top/continew/starter/data/util/QueryWrapperHelper.java index fbf103c7..636ad5a5 100644 --- a/continew-starter-data/continew-starter-data-mf/src/main/java/top/continew/starter/data/util/QueryWrapperHelper.java +++ b/continew-starter-data/continew-starter-data-mf/src/main/java/top/continew/starter/data/util/QueryWrapperHelper.java @@ -30,7 +30,6 @@ import top.continew.starter.core.exception.BadRequestException; import top.continew.starter.core.util.ReflectUtils; import top.continew.starter.core.util.validation.ValidationUtils; import top.continew.starter.data.annotation.Query; -import top.continew.starter.data.annotation.QueryIgnore; import top.continew.starter.data.enums.QueryType; import java.lang.reflect.Field; @@ -140,18 +139,13 @@ public class QueryWrapperHelper { if (ObjectUtil.isEmpty(fieldValue)) { return Collections.emptyList(); } - // 设置了 @QueryIgnore 注解,直接忽略 - QueryIgnore queryIgnoreAnnotation = AnnotationUtil.getAnnotation(field, QueryIgnore.class); - if (queryIgnoreAnnotation != null) { + // 没有 @Query 注解,直接返回 + Query queryAnnotation = AnnotationUtil.getAnnotation(field, Query.class); + if (queryAnnotation == null) { return Collections.emptyList(); } // 建议:数据库表列建议采用下划线连接法命名,程序变量建议采用驼峰法命名 String fieldName = ReflectUtil.getFieldName(field); - // 没有 @Query 注解,默认等值查询 - Query queryAnnotation = AnnotationUtil.getAnnotation(field, Query.class); - if (queryAnnotation == null) { - return Collections.singletonList(q -> q.eq(CharSequenceUtil.toUnderlineCase(fieldName), fieldValue)); - } // 解析单列查询 QueryType queryType = queryAnnotation.type(); String[] columns = queryAnnotation.columns(); diff --git a/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/util/QueryWrapperHelper.java b/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/util/QueryWrapperHelper.java index 135f000d..5ffba3eb 100644 --- a/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/util/QueryWrapperHelper.java +++ b/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/util/QueryWrapperHelper.java @@ -30,7 +30,6 @@ import top.continew.starter.core.exception.BadRequestException; import top.continew.starter.core.util.ReflectUtils; import top.continew.starter.core.util.validation.ValidationUtils; import top.continew.starter.data.annotation.Query; -import top.continew.starter.data.annotation.QueryIgnore; import top.continew.starter.data.enums.QueryType; import top.continew.starter.data.enums.LogicalRelation; @@ -152,18 +151,13 @@ public class QueryWrapperHelper { if (ObjectUtil.isEmpty(fieldValue)) { return Collections.emptyList(); } - // 设置了 @QueryIgnore 注解,直接忽略 - QueryIgnore queryIgnoreAnnotation = AnnotationUtil.getAnnotation(field, QueryIgnore.class); - if (queryIgnoreAnnotation != null) { + // 没有 @Query 注解,直接返回 + Query queryAnnotation = AnnotationUtil.getAnnotation(field, Query.class); + if (queryAnnotation == null) { return Collections.emptyList(); } // 建议:数据库表列建议采用下划线连接法命名,程序变量建议采用驼峰法命名 String fieldName = ReflectUtil.getFieldName(field); - // 没有 @Query 注解,默认等值查询 - Query queryAnnotation = AnnotationUtil.getAnnotation(field, Query.class); - if (queryAnnotation == null) { - return Collections.singletonList(q -> q.eq(CharSequenceUtil.toUnderlineCase(fieldName), fieldValue)); - } // 解析单列查询 QueryType queryType = queryAnnotation.type(); String[] columns = queryAnnotation.columns();