From f0ed88c51eeb35707b4f674ab9ea376b9f556c58 Mon Sep 17 00:00:00 2001 From: Aborn Jiang Date: Tue, 4 Jul 2023 17:32:22 +0800 Subject: [PATCH] support FIND_IN_SET cond (#745) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix weird prefixes keys when use RedisUtils.scan * Column use `` for reserved key ref: https://stackoverflow.com/questions/2224503/how-to-map-an-entity-field-whose-name-is-a-reserved-word-in-jpa * add FIND_IN_SET 条件查询 * note --- .../src/main/java/me/zhengjie/annotation/Query.java | 4 +++- eladmin-common/src/main/java/me/zhengjie/utils/QueryHelp.java | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/eladmin-common/src/main/java/me/zhengjie/annotation/Query.java b/eladmin-common/src/main/java/me/zhengjie/annotation/Query.java index e1758c9b..fe616f1c 100644 --- a/eladmin-common/src/main/java/me/zhengjie/annotation/Query.java +++ b/eladmin-common/src/main/java/me/zhengjie/annotation/Query.java @@ -74,7 +74,9 @@ public @interface Query { // 不为空 ,NOT_NULL // 为空 - ,IS_NULL + ,IS_NULL, + // Aborn Jiang 2022/06/01, 对应SQL: SELECT * FROM table WHERE FIND_IN_SET('querytag', table.tags); + FIND_IN_SET } /** diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/QueryHelp.java b/eladmin-common/src/main/java/me/zhengjie/utils/QueryHelp.java index 671fff71..5b542faa 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/QueryHelp.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/QueryHelp.java @@ -166,6 +166,10 @@ public class QueryHelp { (Comparable) between.get(0), (Comparable) between.get(1))); } break; + case FIND_IN_SET: + list.add(cb.greaterThan(cb.function("FIND_IN_SET", Integer.class, + cb.literal(val.toString()), root.get(attributeName)), 0)); + break; default: break; } }