|
|
|
|
@ -351,14 +351,33 @@ public class WidgetJsonUtil {
@@ -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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|