From 660e006c0d3e6f9cbed2237fdcf3c49831326e1f Mon Sep 17 00:00:00 2001 From: AlexBob Date: Thu, 19 Dec 2024 16:21:53 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(`QueryHelper.java`):=20Add=20n?= =?UTF-8?q?ull=20check=20for=20`objectMap`=20to=20prevent=20NPE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/plate/boot/commons/utils/query/QueryHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boot/platform/src/main/java/com/plate/boot/commons/utils/query/QueryHelper.java b/boot/platform/src/main/java/com/plate/boot/commons/utils/query/QueryHelper.java index a2c3f30..05005ec 100644 --- a/boot/platform/src/main/java/com/plate/boot/commons/utils/query/QueryHelper.java +++ b/boot/platform/src/main/java/com/plate/boot/commons/utils/query/QueryHelper.java @@ -213,7 +213,8 @@ public static QueryFragment query(Object object, Pageable pageable, String prefi */ public static QueryFragment query(Object object, Pageable pageable, Collection skipKeys, String prefix) { Map objectMap = BeanUtils.beanToMap(object, false, true); - Map filterMap = Maps.filterKeys(objectMap, key -> !SKIP_CRITERIA_KEYS.contains(key) && !skipKeys.contains(key)); + Map filterMap = ObjectUtils.isEmpty(objectMap) ? Map.of() : + Maps.filterKeys(objectMap, key -> !SKIP_CRITERIA_KEYS.contains(key) && !skipKeys.contains(key)); QueryFragment queryFragment = QueryFragment.withMap(pageable.getPageSize(), pageable.getOffset(), filterMap); applySort(queryFragment, pageable.getSort(), prefix); @@ -225,7 +226,6 @@ public static QueryFragment query(Object object, Pageable pageable, Collection