Pārlūkot izejas kodu

点赞改查代码提交

pans 8 mēneši atpakaļ
vecāks
revīzija
1666669313

+ 14 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/controller/ResourceTypeController.java

@@ -78,6 +78,20 @@ public class ResourceTypeController {
     public CommonResult<List<Tree<String>>> tree() {
         return CommonResult.data(resourceTypeService.tree());
     }
+
+
+    /**
+     * 获取组织树
+     *
+     * @author xuyuxiang
+     * @date 2022/4/24 20:00
+     */
+    @ApiOperationSupport(order = 2)
+    @ApiOperation("获取组织树")
+    @GetMapping("/disk/type/treeAll")
+    public CommonResult<List<Tree<String>>> treeAll() {
+        return CommonResult.data(resourceTypeService.treeAll());
+    }
     /**
      * 添加resource_type
      *

+ 2 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/service/ResourceTypeService.java

@@ -106,4 +106,6 @@ public interface ResourceTypeService extends IService<ResourceType> {
      * @date 2022/8/15 14:55
      **/
     List<ResourceType> getChildListById(List<ResourceType> originDataList, String id, boolean includeSelf);
+
+    List<Tree<String>> treeAll();
 }

+ 12 - 6
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/service/impl/CollegeServiceImpl.java

@@ -39,7 +39,6 @@ import vip.xiaonuo.disk.mapper.CollegeMapper;
 import vip.xiaonuo.disk.param.*;
 import vip.xiaonuo.disk.service.CollegeService;
 
-import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -97,12 +96,19 @@ public class CollegeServiceImpl extends ServiceImpl<CollegeMapper, College> impl
         List<Tree<String>> list= TreeUtil.build(treeNodeList, "0");
         Tree<String>  tree=new Tree<String>();
         tree.setName("全部");
-        Tree<String> child=new Tree<String>();
-        child.setName("全部");
-        List<Tree<String>> childList=new ArrayList<>();
-        childList.add(child);
-        tree.setChildren(childList);
         list.add(0,tree);
+        for (int i = 1; i < list.size(); i++) {
+            List<Tree<String>> child = list.get(i).getChildren();
+            Tree<String>  tree1=new Tree<String>();
+            tree1.setName("全部");
+            child.add(0,tree1);
+            for (int j = 1; j < child.size(); j++) {
+                List<Tree<String>> gradchild = child.get(j).getChildren();
+                Tree<String>  gradtree=new Tree<String>();
+                gradtree.setName("全部");
+                gradchild.add(0,gradtree);
+            }
+        }
         return list;
     }
 

+ 27 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/service/impl/ResourceTypeServiceImpl.java

@@ -85,6 +85,32 @@ public class ResourceTypeServiceImpl extends ServiceImpl<ResourceTypeMapper, Res
         return TreeUtil.build(treeNodeList, "0");
     }
 
+    @Override
+    public List<Tree<String>> treeAll() {
+        List<ResourceType> collegeList = this.getAllOrgList();
+        List<TreeNode<String>> treeNodeList = collegeList.stream().map(college ->
+                        new TreeNode<>(college.getId(), college.getParentId(),
+                                college.getName(), college.getSortCode()).setExtra(JSONUtil.parseObj(college)))
+                .collect(Collectors.toList());
+        List<Tree<String>> list= TreeUtil.build(treeNodeList, "0");
+        Tree<String>  tree=new Tree<String>();
+        tree.setName("全部");
+        list.add(0,tree);
+        for (int i = 1; i < list.size(); i++) {
+            List<Tree<String>> child = list.get(i).getChildren();
+            Tree<String>  tree1=new Tree<String>();
+            tree1.setName("全部");
+            child.add(0,tree1);
+            for (int j = 1; j < child.size(); j++) {
+                List<Tree<String>> gradchild = child.get(j).getChildren();
+                Tree<String>  gradtree=new Tree<String>();
+                gradtree.setName("全部");
+                gradchild.add(0,gradtree);
+            }
+        }
+        return list;
+    }
+
 
 
 
@@ -150,6 +176,7 @@ public class ResourceTypeServiceImpl extends ServiceImpl<ResourceTypeMapper, Res
     }
 
 
+
     public void execRecursionFindChild(List<ResourceType> originDataList, String id, List<ResourceType> resultList) {
         originDataList.forEach(item -> {
             if(item.getParentId().equals(id)) {