mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-10-14 02:57:08 +08:00
refactor(data): 移除 QueryIgnore 注解,并取消默认 eq 逻辑处理
This commit is contained in:
@@ -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 {}
|
@@ -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();
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user