|
@@ -26,7 +26,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -69,15 +71,46 @@ public class NetdiskServiceImpl extends ServiceImpl<NetdiskMapper, Netdisk> impl
|
|
|
return treeRecursion(list,-1l);
|
|
|
}
|
|
|
|
|
|
- private List<NetdiskVo> treeRecursion(List<Netdisk> list, Long id){
|
|
|
+ private List<NetdiskVo> treeRecursion(List<Netdisk> list, Long id) {
|
|
|
List<Netdisk> netdiskList = list.stream().filter(f -> f.getParentFolderId().equals(id)).collect(Collectors.toList());
|
|
|
List<NetdiskVo> netdiskVos = BeanUtil.copyToList(netdiskList, NetdiskVo.class);
|
|
|
- for (NetdiskVo netdisk :netdiskVos){
|
|
|
- netdisk.setNetdiskList(treeRecursion(list,netdisk.getId()));
|
|
|
+ for (NetdiskVo netdisk : netdiskVos) {
|
|
|
+ netdisk.setNetdiskList(treeRecursion(list, netdisk.getId()));
|
|
|
}
|
|
|
return netdiskVos;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 递归文件夹获取文件夹下的所有文件以及子文件夹下的文件
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<Netdisk> getFileList(NetdiskDto dto) {
|
|
|
+ Long parentFolderId = dto.getParentFolderId();
|
|
|
+ if (ObjectUtil.isEmpty(parentFolderId)) {
|
|
|
+ parentFolderId = -1L;
|
|
|
+ }
|
|
|
+ return fileRecursion(Arrays.asList(parentFolderId));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 递归文件夹获取文件夹下的所有文件以及子文件夹下的文件
|
|
|
+ */
|
|
|
+ private List<Netdisk> fileRecursion(List<Long> parentFolderIds) {
|
|
|
+ List<Netdisk> list = this.list(q -> q.in(Netdisk::getParentFolderId, parentFolderIds));
|
|
|
+
|
|
|
+
|
|
|
+ List<Netdisk> collect = list.stream().filter(item -> Objects.equals(item.getType(), 2)).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ List<Long> parentFolderIds1 = list.stream().filter(item -> Objects.equals(item.getType(), 1)).map(Netdisk::getId).collect(Collectors.toList());
|
|
|
+ if (ObjectUtil.isNotEmpty(parentFolderIds1)) {
|
|
|
+ List<Netdisk> netdiskList = fileRecursion(parentFolderIds1);
|
|
|
+ collect.addAll(netdiskList);
|
|
|
+ }
|
|
|
+
|
|
|
+ return collect;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public NetdiskVo detail(Long id) {
|
|
|
Netdisk Netdisk = this.getById(id);
|