Skip to content

Commit c8e8d87

Browse files
committed
Server:完成 key@:{} 对应的 = 类型子查询
1 parent 355d229 commit c8e8d87

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

APIJSON-Java-Server/APIJSONLibrary/src/main/java/zuo/biao/apijson/server/AbstractObjectParser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,10 @@ public boolean onParse(@NotNull String key, @NotNull Object value) throws Except
349349
throw new IllegalArgumentException("子查询 " + path + "/" + key + ":{ from:value } 中 value 对应的主表对象不存在!");
350350
}
351351
//
352-
SQLConfig cfg = arrObj == null ? null : (SQLConfig) arrObj.get(AbstractParser.KEY_CONFIG);
352+
SQLConfig cfg = (SQLConfig) arrObj.get(AbstractParser.KEY_CONFIG);
353+
if (cfg == null) {
354+
throw new NotExistException(TAG + ".onParse cfg == null");
355+
}
353356

354357
Subquery s = new Subquery();
355358
s.setPath(path);

APIJSON-Java-Server/APIJSONLibrary/src/main/java/zuo/biao/apijson/server/AbstractSQLConfig.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ else if (key.endsWith("<>")) {
11401140

11411141

11421142
@JSONField(serialize = false)
1143-
public String getEqualString(String key, Object value) {
1143+
public String getEqualString(String key, Object value) throws Exception {
11441144
if (value instanceof Collection<?>) {
11451145
throw new IllegalArgumentException(key + ":value 中value不合法!非PUT请求只支持 [Boolean, Number, String] 内的类型 !");
11461146
}
@@ -1152,7 +1152,8 @@ public String getEqualString(String key, Object value) {
11521152
if (StringUtil.isName(key) == false) {
11531153
throw new IllegalArgumentException(key + ":value 中key不合法!不支持 ! 以外的逻辑符 !");
11541154
}
1155-
return getKey(key) + (not ? "!=" : "=") + getValue(value);
1155+
1156+
return getKey(key) + (not ? "!=" : "=") + (value instanceof Subquery ? getSubqueryString((Subquery) value) : getValue(value));
11561157
}
11571158

11581159
public String getKey(String key) {
@@ -1852,13 +1853,13 @@ else if (id instanceof String) {
18521853
throw new NotExistException(TAG + ": newSQLConfig StringUtil.isEmpty(" + table + ".id, true)");
18531854
}
18541855
}
1856+
else if (id instanceof Subquery) {}
18551857
else {
1856-
throw new IllegalArgumentException(KEY_ID + ":value 中 value 的类型只能是 Long  String !");
1858+
throw new IllegalArgumentException(KEY_ID + ":value 中 value 的类型只能是 Long , String 或 Subquery !");
18571859
}
18581860

1859-
if (idIn != null && idIn instanceof List) { //共用idIn场景少性能差
1860-
if (idIn != null && ((List<?>) idIn).contains(id) == false) {//empty有效 BaseModel.isEmpty(idIn) == false) {
1861-
Log.w(TAG, "newSQLConfig id > 0 >> idInObj != null && idInObj.contains(id) == false >> return null;");
1861+
if (idIn instanceof List) { //共用idIn场景少性能差
1862+
if (((List<?>) idIn).contains(id) == false) {//empty有效 BaseModel.isEmpty(idIn) == false) {
18621863
throw new NotExistException(TAG + ": newSQLConfig idIn != null && ((JSONArray) idIn).contains(id) == false");
18631864
}
18641865
}

0 commit comments

Comments
 (0)