Skip to content

Commit 602ad59

Browse files
committed
update 2.8.8
1 parent d0bb08a commit 602ad59

File tree

8 files changed

+47
-10
lines changed

8 files changed

+47
-10
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<groupId>com.codingapi.springboot</groupId>
1414
<artifactId>springboot-parent</artifactId>
15-
<version>2.8.7</version>
15+
<version>2.8.8</version>
1616

1717
<url>https://github.com/codingapi/springboot-framewrok</url>
1818
<name>springboot-parent</name>

springboot-starter-data-fast/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-parent</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>2.8.7</version>
8+
<version>2.8.8</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

springboot-starter-data-fast/src/main/java/com/codingapi/springboot/fast/jpa/repository/DynamicSQLBuilder.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ private void buildSQL(Filter filter, StringBuilder hql) {
103103
params.add("%" + filter.getValue()[0] + "%");
104104
paramIndex++;
105105
}
106+
if (filter.isLeftLike()) {
107+
hql.append(filter.getKey()).append(" LIKE ?").append(paramIndex);
108+
params.add("%" + filter.getValue()[0]);
109+
paramIndex++;
110+
}
111+
if (filter.isRightLike()) {
112+
hql.append(filter.getKey()).append(" LIKE ?").append(paramIndex);
113+
params.add(filter.getValue()[0] + "%");
114+
paramIndex++;
115+
}
106116
if (filter.isIn()) {
107117
hql.append(filter.getKey()).append(" IN (").append("?").append(paramIndex).append(")");
108118
params.add(Arrays.asList(filter.getValue()));
@@ -140,4 +150,4 @@ private void buildSQL(Filter filter, StringBuilder hql) {
140150
public Object[] getParams() {
141151
return params.toArray();
142152
}
143-
}
153+
}

springboot-starter-security/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>2.8.7</version>
9+
<version>2.8.8</version>
1010
</parent>
1111

1212
<artifactId>springboot-starter-security</artifactId>

springboot-starter/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.codingapi.springboot</groupId>
77
<artifactId>springboot-parent</artifactId>
8-
<version>2.8.7</version>
8+
<version>2.8.8</version>
99
</parent>
1010
<artifactId>springboot-starter</artifactId>
1111

springboot-starter/src/main/java/com/codingapi/springboot/framework/dto/request/Filter.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ public boolean isLike() {
5252
return relation == Relation.LIKE;
5353
}
5454

55+
56+
public boolean isLeftLike() {
57+
return relation == Relation.LEFT_LIKE;
58+
}
59+
60+
public boolean isRightLike() {
61+
return relation == Relation.RIGHT_LIKE;
62+
}
63+
64+
5565
public boolean isBetween() {
5666
return relation == Relation.BETWEEN;
5767
}

springboot-starter/src/main/java/com/codingapi/springboot/framework/dto/request/Relation.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ public enum Relation {
44

55
EQUAL,
66
LIKE,
7+
LEFT_LIKE,
8+
RIGHT_LIKE,
79
BETWEEN,
810
IN,
911
GREATER_THAN,

springboot-starter/src/main/java/com/codingapi/springboot/framework/dto/request/SearchRequest.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,34 @@ public void addFilter(String key, List<String> value) {
137137
}
138138

139139

140+
140141
private Class<?> getKeyType(String key) {
141142
String[] keys = key.split("\\.");
142143
Class<?> keyClass = clazz;
144+
143145
for (String k : keys) {
144-
Field[] fields = keyClass.getDeclaredFields();
146+
keyClass = findFieldInHierarchy(keyClass, k);
147+
148+
if (keyClass == null) {
149+
throw new IllegalArgumentException("Field " + k + " not found in class hierarchy.");
150+
}
151+
}
152+
return keyClass;
153+
}
154+
155+
private Class<?> findFieldInHierarchy(Class<?> clazz, String fieldName) {
156+
Class<?> currentClass = clazz;
157+
158+
while (currentClass != null) {
159+
Field[] fields = currentClass.getDeclaredFields();
145160
for (Field field : fields) {
146-
if (field.getName().equals(k)) {
147-
keyClass = field.getType();
148-
break;
161+
if (field.getName().equals(fieldName)) {
162+
return field.getType();
149163
}
150164
}
165+
currentClass = currentClass.getSuperclass(); // 向上查找父类
151166
}
152-
return keyClass;
167+
return null;
153168
}
154169

155170
}

0 commit comments

Comments
 (0)