mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-09-08 16:57:09 +08:00
fix(data/mp): 修复 Query 范围查询数组类型数据解析错误
This commit is contained in:
@@ -33,10 +33,7 @@ import top.continew.starter.data.core.enums.QueryType;
|
||||
import top.continew.starter.data.core.util.SqlInjectionUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@@ -193,8 +190,9 @@ public class QueryWrapperHelper {
|
||||
case LT -> consumers.add(q -> q.lt(columnName, fieldValue));
|
||||
case LE -> consumers.add(q -> q.le(columnName, fieldValue));
|
||||
case BETWEEN -> {
|
||||
// 数组转集合
|
||||
List<Object> between = new ArrayList<>(ArrayUtil.isArray(fieldValue)
|
||||
? CollUtil.toList(fieldValue)
|
||||
? List.of((Object[])fieldValue)
|
||||
: (List<Object>)fieldValue);
|
||||
ValidationUtils.throwIf(between.size() != 2, "[{}] 必须是一个范围", columnName);
|
||||
consumers.add(q -> q.between(columnName, between.get(0), between.get(1)));
|
||||
@@ -205,13 +203,13 @@ public class QueryWrapperHelper {
|
||||
case IN -> {
|
||||
ValidationUtils.throwIfEmpty(fieldValue, "[{}] 不能为空", columnName);
|
||||
consumers.add(q -> q.in(columnName, ArrayUtil.isArray(fieldValue)
|
||||
? CollUtil.toList(fieldValue)
|
||||
? List.of((Object[])fieldValue)
|
||||
: (Collection<Object>)fieldValue));
|
||||
}
|
||||
case NOT_IN -> {
|
||||
ValidationUtils.throwIfEmpty(fieldValue, "[{}] 不能为空", columnName);
|
||||
consumers.add(q -> q.notIn(columnName, ArrayUtil.isArray(fieldValue)
|
||||
? CollUtil.toList(fieldValue)
|
||||
? List.of((Object[])fieldValue)
|
||||
: (Collection<Object>)fieldValue));
|
||||
}
|
||||
case IS_NULL -> consumers.add(q -> q.isNull(columnName));
|
||||
|
Reference in New Issue
Block a user