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();