Commit 57e1a36a by 284718418@qq.com

1.我的文件文件夹或共享空间列表接口

parent 0cae80f0
......@@ -14,7 +14,7 @@ public interface DiskCatalogueService {
/**
* 文件文件夹或共享空间列表
* @param orgId
* @param UserId
* @param userId
* @param type
* @return
*/
......
package cn.timer.api.controller.disk.sevice;
import cn.timer.api.bean.disk.DiskCatalogue;
import cn.timer.api.bean.disk.DiskCatalogueFiles;
import cn.timer.api.bean.disk.DiskFiles;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -17,8 +20,12 @@ import java.util.stream.Collectors;
*/
@Service
public class DiskCatalogueServiceImpl implements DiskCatalogueService {
//所有文件夹
private static List<DiskCatalogue> treeList = new ArrayList<>();
//所有文件
private static List<DiskFiles> filesList = new ArrayList<>();
//所有文件夹ID
private static Map<Integer, List<DiskCatalogueFiles>> map = new HashMap<Integer, List<DiskCatalogueFiles>>();
@Override
public List<DiskCatalogue> getDiskCatalogueList(Integer orgId, Integer userId, Integer type) {
......@@ -26,7 +33,25 @@ public class DiskCatalogueServiceImpl implements DiskCatalogueService {
.lambda().eq(DiskCatalogue::getOrgId, orgId)
.eq(DiskCatalogue::getCreateUserId, userId)
.eq(DiskCatalogue::getType, type)
.eq(DiskCatalogue::getDeleteFlag, 0)
);
if (treeList.size() == 0) {
return treeList;
}
filesList = DiskFiles.builder().build().selectList(new QueryWrapper<DiskFiles>()
.lambda().eq(DiskFiles::getCreateUserId, userId)
.eq(DiskFiles::getDeleteFlag, 0)
);
List<DiskCatalogueFiles> diskCatalogueFilesList = DiskCatalogueFiles.builder().build().selectList(new QueryWrapper<DiskCatalogueFiles>()
.lambda().in(DiskCatalogueFiles::getCatalogueId, treeList.stream().map(item -> item.getId()).collect(Collectors.toList()))
.eq(DiskCatalogueFiles::getDeleteFlag, 0)
);
//根据CatalogueId分组
map = diskCatalogueFilesList.stream().collect(Collectors.groupingBy(DiskCatalogueFiles::getCatalogueId));
List<DiskCatalogue> list = treeList.stream().filter(s -> s.getParentId() == 0).collect(Collectors.toList());
return getTree(list);
......@@ -56,6 +81,13 @@ public class DiskCatalogueServiceImpl implements DiskCatalogueService {
*/
public static DiskCatalogue recursiveTree(Integer cid) {
DiskCatalogue node = getMenuById(cid);
//填充文件夹下所有文件
List<DiskCatalogueFiles> diskCatalogueFilesList = (List<DiskCatalogueFiles>) map.get(cid);
if (!CollectionUtils.isEmpty(diskCatalogueFilesList)) {
List<Integer> ids = diskCatalogueFilesList.stream().map(item -> item.getFilesId()).collect(Collectors.toList());
List<DiskFiles> diskFilesList = filesList.stream().filter(item -> ids.contains(item.getId())).collect(Collectors.toList());
node.setDiskFilesList(diskFilesList);
}
List<DiskCatalogue> childTreeNodes = getChildTreeById(cid);
for (DiskCatalogue child : childTreeNodes) {
DiskCatalogue n = recursiveTree(child.getId());
......@@ -94,7 +126,7 @@ public class DiskCatalogueServiceImpl implements DiskCatalogueService {
}
/**
* 根据父节点CID获取所有节点
* 根据父节点CID获取所有节点
*/
public static List<DiskCatalogue> getChildTreeById(Integer cid) {
List<DiskCatalogue> list = new ArrayList<>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment