refactor(data): 移除 QueryIgnore 注解,并取消默认 eq 逻辑处理

This commit is contained in:
2025-09-21 19:13:20 +08:00
parent e414abc735
commit e9a6f36136
3 changed files with 6 additions and 48 deletions

View File

@@ -1,30 +0,0 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
* <p>
* 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
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <p>
* 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 {}

View File

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

View File

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