Просмотр исходного кода

更新文件 SmartAuthorGroupServiceImpl.java

陈士柏 2 лет назад
Родитель
Сommit
2bed9d25f6
1 измененных файлов с 14 добавлено и 10 удалено
  1. 14 10
      src/main/java/com/template/services/impl/SmartAuthorGroupServiceImpl.java

+ 14 - 10
src/main/java/com/template/services/impl/SmartAuthorGroupServiceImpl.java

@@ -149,11 +149,13 @@ public class SmartAuthorGroupServiceImpl extends ServiceImpl<SmartAuthorGroupMap
                     queryWrapper1.in("id", Arrays.asList(manageId));
                     queryWrapper1.in("id", Arrays.asList(manageId));
                     List<SmartDepartment> list1 = smartDepartmentMapper.selectList(queryWrapper1);
                     List<SmartDepartment> list1 = smartDepartmentMapper.selectList(queryWrapper1);
                     List<JSONObject> departmentManageJson = new ArrayList<>();
                     List<JSONObject> departmentManageJson = new ArrayList<>();
-                    for (int j = 0; j < list1.size(); j++) {
-                        JSONObject jsonObject1 = new JSONObject();
-                        jsonObject1.put("id", list1.get(i).getId());
-                        jsonObject1.put("name", list1.get(i).getName());
-                        departmentManageJson.add(jsonObject1);
+                    if (list1.size()>0){
+                        for (int j = 0; j < list1.size(); j++) {
+                            JSONObject jsonObject1 = new JSONObject();
+                            jsonObject1.put("id", list1.get(i).getId());
+                            jsonObject1.put("name", list1.get(i).getName());
+                            departmentManageJson.add(jsonObject1);
+                        }
                     }
                     }
                     list.get(i).setDepartmentManageJson(departmentManageJson);
                     list.get(i).setDepartmentManageJson(departmentManageJson);
                 }
                 }
@@ -164,11 +166,13 @@ public class SmartAuthorGroupServiceImpl extends ServiceImpl<SmartAuthorGroupMap
                     queryWrapper1.in("id", Arrays.asList(viewId));
                     queryWrapper1.in("id", Arrays.asList(viewId));
                     List<SmartDepartment> list1 = smartDepartmentMapper.selectList(queryWrapper1);
                     List<SmartDepartment> list1 = smartDepartmentMapper.selectList(queryWrapper1);
                     List<JSONObject> departmentViewJson = new ArrayList<>();
                     List<JSONObject> departmentViewJson = new ArrayList<>();
-                    for (int j = 0; j < list1.size(); j++) {
-                        JSONObject jsonObject1 = new JSONObject();
-                        jsonObject1.put("id", list1.get(i).getId());
-                        jsonObject1.put("name", list1.get(i).getName());
-                        departmentViewJson.add(jsonObject1);
+                    if (list1.size()>0){
+                        for (int j = 0; j < list1.size(); j++) {
+                            JSONObject jsonObject1 = new JSONObject();
+                            jsonObject1.put("id", list1.get(i).getId());
+                            jsonObject1.put("name", list1.get(i).getName());
+                            departmentViewJson.add(jsonObject1);
+                        }
                     }
                     }
                     list.get(i).setDepartmentViewJson(departmentViewJson);
                     list.get(i).setDepartmentViewJson(departmentViewJson);
                 }
                 }