|
@@ -425,38 +425,55 @@ public class DatabaseServiceImpl implements DatabaseService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ResponseJson uploadPackage(Integer authUserId,String fileName, String ossName, String ossUrl, String fileSize,Integer parentId,String mime,String filePath){
|
|
|
|
|
|
+ public ResponseJson uploadPackage(Integer authUserId,List<FileTreeVo> fileTreeVos){
|
|
//如果文件夹没有文件则直接返回
|
|
//如果文件夹没有文件则直接返回
|
|
- if(StringUtils.isNotEmpty(filePath)){
|
|
|
|
- if(!filePath.contains(".")){
|
|
|
|
- ResponseJson.error("-1","文件夹为空");
|
|
|
|
- }
|
|
|
|
- String[] filePathArr = filePath.split("/");
|
|
|
|
- for (int i=0 ;i<filePathArr.length;i++){
|
|
|
|
- if(filePathArr[i].contains(".")){
|
|
|
|
- //新增文件
|
|
|
|
- getOssUploadResult(authUserId,fileName,ossName,ossUrl,fileSize,parentId,mime);
|
|
|
|
- System.out.println("文件---------"+filePathArr[i]);
|
|
|
|
- }else{
|
|
|
|
- //创建文件夹
|
|
|
|
- //判断文件夹是否存在(不存在则新建,存在则跳过)
|
|
|
|
- List<Integer> dictionaryById = fileMapper.findDictionaryById(parentId);
|
|
|
|
- if(null!=dictionaryById&&dictionaryById.size()>0){
|
|
|
|
- continue;
|
|
|
|
- }else{
|
|
|
|
- //不存在创建文件夹
|
|
|
|
- fileMapper.creatPackage(authUserId, parentId, filePathArr[i]);
|
|
|
|
- //查询最新文件夹id作为下一次的父id
|
|
|
|
- List<Integer> newestInfoById = fileMapper.getNewestInfoById();
|
|
|
|
- if(null!=newestInfoById&&newestInfoById.size()>0){
|
|
|
|
- parentId = newestInfoById.get(0);
|
|
|
|
|
|
+ for (FileTreeVo fileTreeVo:fileTreeVos) {
|
|
|
|
+ if (StringUtils.isNotEmpty(fileTreeVo.getFilePath())) {
|
|
|
|
+ if (!fileTreeVo.getFilePath().contains(".")) {
|
|
|
|
+ ResponseJson.error("-1", "文件夹为空");
|
|
|
|
+ }
|
|
|
|
+ String[] filePathArr = fileTreeVo.getFilePath().split("/");
|
|
|
|
+ for (int i = 0; i < filePathArr.length; i++) {
|
|
|
|
+ if (filePathArr[i].contains(".")) {
|
|
|
|
+ //新增文件
|
|
|
|
+ getOssUploadResult(authUserId, filePathArr[i], fileTreeVo.getOssName(), fileTreeVo.getOssUrl(), fileTreeVo.getFileSize(), fileTreeVo.getParentId(), fileTreeVo.getMime());
|
|
|
|
+ System.out.println("文件---------" + filePathArr[i]);
|
|
|
|
+ } else {
|
|
|
|
+ //判断是否根目录
|
|
|
|
+ List<Integer> dictionaryById=new ArrayList<>();
|
|
|
|
+ if(null!=fileTreeVo.getParentId()&&0==fileTreeVo.getParentId()){
|
|
|
|
+ dictionaryById=fileMapper.findDictionaryById(null,filePathArr[i]);
|
|
|
|
+ }else{
|
|
|
|
+ dictionaryById = fileMapper.findDictionaryById(fileTreeVo.getParentId(),filePathArr[i]);
|
|
|
|
+ if(null==dictionaryById||dictionaryById.size()<=0){
|
|
|
|
+ //判断次级目录是否存在
|
|
|
|
+ List<Integer> secondDictionaryById = fileMapper.findSecondDictionaryById(fileTreeVo.getParentId(), filePathArr[i]);
|
|
|
|
+ if(null!=secondDictionaryById&&secondDictionaryById.size()>0){
|
|
|
|
+ dictionaryById.add(secondDictionaryById.get(0));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //创建文件夹
|
|
|
|
+ //判断文件夹是否存在(不存在则新建,存在则跳过)
|
|
|
|
+ if (null != dictionaryById && dictionaryById.size() > 0) {
|
|
|
|
+ fileTreeVo.setParentId(dictionaryById.get(0));
|
|
|
|
+ continue;
|
|
|
|
+ } else {
|
|
|
|
+ //不存在创建文件夹
|
|
|
|
+ fileMapper.creatPackage(authUserId, fileTreeVo.getParentId(), filePathArr[i]);
|
|
|
|
+ //查询最新文件夹id作为下一次的父id
|
|
|
|
+ List<Integer> newestInfoById = fileMapper.getNewestInfoById();
|
|
|
|
+ if (null != newestInfoById && newestInfoById.size() > 0) {
|
|
|
|
+ fileTreeVo.setParentId(newestInfoById.get(0));
|
|
|
|
+// parentId = newestInfoById.get(0);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ System.out.println("文件夹---------" + filePathArr[i]);
|
|
}
|
|
}
|
|
- System.out.println("文件夹---------"+filePathArr[i]);
|
|
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ ResponseJson.error("-1", "文件夹为空");
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
- ResponseJson.error("-1","文件夹为空");
|
|
|
|
}
|
|
}
|
|
return ResponseJson.success();
|
|
return ResponseJson.success();
|
|
}
|
|
}
|