TASK:AiDA design like sort、moodboardPosition
This commit is contained in:
@@ -175,25 +175,45 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
|
||||
String styleData = position.getStyleData();
|
||||
int sequence = position.getSequence(); // 获取 sequence 值
|
||||
|
||||
// 如果 type 字段还没有对应的 JSONArray,则初始化它
|
||||
if (!resultJson.containsKey(type)) {
|
||||
resultJson.put(type, new ArrayList<>());
|
||||
// 如果 type 字段为 "class",直接将其作为字符串处理
|
||||
if ("class".equals(type)) {
|
||||
// 如果 type 字段还没有对应的 JSONArray,则初始化它
|
||||
if (!resultJson.containsKey(type)) {
|
||||
resultJson.put(type, new ArrayList<>());
|
||||
}
|
||||
|
||||
// 获取对应类型的列表
|
||||
List<String> classList = (List<String>) resultJson.get(type);
|
||||
|
||||
// 确保列表长度足够,可以容纳 `sequence` 索引
|
||||
while (classList.size() <= sequence) {
|
||||
classList.add(""); // 添加空字符串,直到长度大于 `sequence`
|
||||
}
|
||||
|
||||
// 将 class 字段直接存入列表
|
||||
classList.set(sequence, styleData); // 根据 sequence 设置数据
|
||||
|
||||
resultJson.put(type, classList);
|
||||
} else {
|
||||
// 如果 type 字段为其他类型,按照正常方式处理
|
||||
if (!resultJson.containsKey(type)) {
|
||||
resultJson.put(type, new ArrayList<>());
|
||||
}
|
||||
|
||||
// 获取对应类型的列表
|
||||
List<JSONObject> styleList = (List<JSONObject>) resultJson.get(type);
|
||||
|
||||
// 确保列表长度足够,可以容纳 `sequence` 索引
|
||||
while (styleList.size() <= sequence) {
|
||||
styleList.add(new JSONObject()); // 添加空的 JSONObject,直到长度大于 `sequence`
|
||||
}
|
||||
|
||||
// 将解析的样式数据存入正确的索引位置
|
||||
JSONObject styleObject = JSON.parseObject(styleData);
|
||||
styleList.set(sequence, styleObject); // 根据 sequence 设置数据
|
||||
|
||||
resultJson.put(type, styleList);
|
||||
}
|
||||
|
||||
// 获取对应类型的列表
|
||||
List<JSONObject> styleList = (List<JSONObject>) resultJson.get(type);
|
||||
|
||||
// 确保列表长度足够,可以容纳 `sequence` 索引
|
||||
while (styleList.size() <= sequence) {
|
||||
styleList.add(new JSONObject()); // 添加空的 JSONObject,直到长度大于 `sequence`
|
||||
}
|
||||
|
||||
// 将解析的样式数据存入正确的索引位置
|
||||
JSONObject styleObject = JSON.parseObject(styleData);
|
||||
styleList.set(sequence, styleObject); // 根据 sequence 设置数据
|
||||
|
||||
// 更新回 resultJson
|
||||
resultJson.put(type, styleList);
|
||||
}
|
||||
|
||||
// 将最终结果转换为字符串
|
||||
|
||||
Reference in New Issue
Block a user