Skip to content

Commit 8d780dd

Browse files
committed
解决表对象中的子表对象数据总是一样以及在 Table[]:{ Table:{ ChildTable:{} } } 情况下只有首个 Table 里返回了 ChildTable
1 parent ed036ef commit 8d780dd

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,16 @@ public AbstractObjectParser(@NotNull JSONObject request, String parentPath, SQLC
112112

113113
}
114114

115-
115+
@Override
116+
public String getParentPath() {
117+
return parentPath;
118+
}
119+
120+
@Override
121+
public AbstractObjectParser setParentPath(String parentPath) {
122+
this.parentPath = parentPath;
123+
return this;
124+
}
116125

117126
protected int position;
118127
public int getPosition() {
@@ -144,7 +153,6 @@ public boolean isBreakParse() {
144153
protected String table;
145154
protected String alias;
146155
protected boolean isReuse;
147-
protected String parentName;
148156
protected String path;
149157

150158
protected JSONObject response;
@@ -824,7 +832,7 @@ public void onChildResponse() throws Exception {
824832
continue;
825833
}
826834

827-
response.put(entry.getKey(), child );
835+
response.put(entry.getKey(), child);
828836
index ++;
829837
}
830838
}
@@ -856,14 +864,14 @@ public JSONObject onSQLExecute() throws Exception {
856864

857865
isSimpleArray = (functionMap == null || functionMap.isEmpty())
858866
&& (customMap == null || customMap.isEmpty())
867+
&& (childMap == null || childMap.isEmpty())
859868
&& (table.equals(arrayTable));
860869

861870
// 提取并缓存数组主表的列表数据
862871
rawList = (List<JSONObject>) result.remove(SQLExecutor.KEY_RAW_LIST);
863872
if (rawList != null) {
864873
String arrayPath = parentPath.substring(0, parentPath.lastIndexOf("[]") + 2);
865874

866-
867875
if (isSimpleArray == false) {
868876
long startTime = System.currentTimeMillis();
869877

APIJSONORM/src/main/java/apijson/orm/AbstractParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ public JSONObject onObjectParse(final JSONObject request
855855
ObjectParser op = null;
856856
if (isReuse) { // 数组主表使用专门的缓存数据
857857
op = arrayObjectParserCacheMap.get(parentPath.substring(0, parentPath.lastIndexOf("[]") + 2));
858+
op.setParentPath(parentPath);
858859
}
859860

860861
if (op == null) {

APIJSONORM/src/main/java/apijson/orm/ObjectParser.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
*/
2121
public interface ObjectParser {
2222

23+
String getParentPath();
24+
ObjectParser setParentPath(String parentPath);
25+
2326
/**解析成员
2427
* response重新赋值
2528
* @param parentPath
@@ -140,7 +143,6 @@ public interface ObjectParser {
140143
void recycle();
141144

142145

143-
144146
ObjectParser setMethod(RequestMethod method);
145147
RequestMethod getMethod();
146148

0 commit comments

Comments
 (0)