diff --git a/common/common-online/src/main/java/apelet/common/online/util/WidgetJsonUtil.java b/common/common-online/src/main/java/apelet/common/online/util/WidgetJsonUtil.java index d0cbf34..8c9d3c3 100644 --- a/common/common-online/src/main/java/apelet/common/online/util/WidgetJsonUtil.java +++ b/common/common-online/src/main/java/apelet/common/online/util/WidgetJsonUtil.java @@ -351,14 +351,33 @@ public class WidgetJsonUtil { * @param tableId 子表Id。 */ public static void backfillTableId(JSONObject widgetJson, String tableName, Long tableId) { - walkAllModes(widgetJson, widget -> { + if (widgetJson == null) return; + for (String mode : new String[]{"pc", "mobile"}) { + JSONObject modeObj = widgetJson.getJSONObject(mode); + if (modeObj == null) continue; + backfillTableIdInWidgets(modeObj.getJSONArray("widgetList"), tableName, tableId); + JSONObject tableWidget = modeObj.getJSONObject("tableWidget"); + if (tableWidget != null) { + backfillTableIdInWidgets(tableWidget.getJSONArray("childWidgetList"), tableName, tableId); + } + } + } + + private static void backfillTableIdInWidgets(JSONArray widgetList, String tableName, Long tableId) { + if (CollUtil.isEmpty(widgetList)) return; + for (int i = 0; i < widgetList.size(); i++) { + JSONObject widget = widgetList.getJSONObject(i); + if (widget == null) continue; if (widget.getInteger("widgetType") != null && 100 == widget.getInteger("widgetType")) { JSONObject bindData = widget.getJSONObject("bindData"); if (bindData != null && tableName.equals(bindData.getString("tableName"))) { bindData.put("tableId", tableId); } + continue; } - }); + JSONArray childWidgetList = widget.getJSONArray("childWidgetList"); + if (CollUtil.isNotEmpty(childWidgetList)) backfillTableIdInWidgets(childWidgetList, tableName, tableId); + } } /**