|
@@ -1863,13 +1863,13 @@ public class BatchServiceImpl implements IBatchService {
|
|
if (!Check.isNull(details)) {
|
|
if (!Check.isNull(details)) {
|
|
JSONArray returnArr = new JSONArray();
|
|
JSONArray returnArr = new JSONArray();
|
|
for (int i = 0; i < details.size(); i++) {
|
|
for (int i = 0; i < details.size(); i++) {
|
|
- JSONObject jsonObject = details.getJSONObject(i);
|
|
|
|
|
|
+ JSONObject firstJson = details.getJSONObject(i);
|
|
|
|
|
|
- String level = jsonObject.getString("level");
|
|
|
|
- if ("1".equals(level)) {
|
|
|
|
- JSONArray LevelArr = getSubLevel(jsonObject.getInteger("category_id"), details);
|
|
|
|
- jsonObject.put("child", LevelArr);
|
|
|
|
- returnArr.add(jsonObject);
|
|
|
|
|
|
+ Integer parent_id = firstJson.getInteger("parent_id");
|
|
|
|
+ if (0 == parent_id) {
|
|
|
|
+ JSONArray LevelArr = getSecond(firstJson.getString("category_id"), details);
|
|
|
|
+ firstJson.put("child", LevelArr);
|
|
|
|
+ returnArr.add(firstJson);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return returnArr;
|
|
return returnArr;
|
|
@@ -1884,19 +1884,13 @@ public class BatchServiceImpl implements IBatchService {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- private JSONArray getSubLevel(Integer categoryId, JSONArray details) {
|
|
|
|
|
|
+ private JSONArray getSecond(String categoryId, JSONArray details) {
|
|
|
|
|
|
JSONArray secondArr = new JSONArray();
|
|
JSONArray secondArr = new JSONArray();
|
|
for (int i = 0; i < details.size(); i++) {
|
|
for (int i = 0; i < details.size(); i++) {
|
|
JSONObject secondJson = details.getJSONObject(i);
|
|
JSONObject secondJson = details.getJSONObject(i);
|
|
- if ("2".equals(secondJson.getString("level")) && categoryId.equals(secondJson.getInteger("parent_id"))) {
|
|
|
|
- JSONArray thirdArr = new JSONArray();
|
|
|
|
- for (int j = 0; j < details.size(); j++) {
|
|
|
|
- JSONObject thirdJson = details.getJSONObject(j);
|
|
|
|
- if ("3".equals(thirdJson.getString("level")) && secondJson.getInteger("category_id").equals(thirdJson.getInteger("parent_id"))) {
|
|
|
|
- thirdArr.add(thirdJson);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (categoryId.equals(secondJson.getString("parent_id"))) {
|
|
|
|
+ JSONArray thirdArr = getThird(secondJson.getString("category_id"), details);
|
|
secondJson.put("child", thirdArr);
|
|
secondJson.put("child", thirdArr);
|
|
secondArr.add(secondJson);
|
|
secondArr.add(secondJson);
|
|
}
|
|
}
|
|
@@ -1904,6 +1898,19 @@ public class BatchServiceImpl implements IBatchService {
|
|
return secondArr;
|
|
return secondArr;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ private JSONArray getThird(String categoryId, JSONArray details) {
|
|
|
|
+ JSONArray thirdArr = new JSONArray();
|
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
|
+ JSONObject thirdJson = details.getJSONObject(i);
|
|
|
|
+ String parent_id = thirdJson.getString("parent_id");
|
|
|
|
+ if (categoryId.equals(parent_id)) {
|
|
|
|
+ thirdArr.add(thirdJson);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return thirdArr;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|