|
@@ -15,13 +15,12 @@ import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.Assert;
|
|
import org.springframework.util.Assert;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.ServletOutputStream;
|
|
import javax.servlet.ServletOutputStream;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
-import java.io.File;
|
|
|
|
-import java.io.FileInputStream;
|
|
|
|
-import java.io.IOException;
|
|
|
|
|
|
+import java.io.*;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -373,4 +372,50 @@ public class DatabaseServiceImpl implements DatabaseService {
|
|
private List<FileTreeVo> existsPackageOrCommonFile(Integer fileId, Integer authUserId, Integer selectFor) {
|
|
private List<FileTreeVo> existsPackageOrCommonFile(Integer fileId, Integer authUserId, Integer selectFor) {
|
|
return fileMapper.findSonPackage(fileId, authUserId, selectFor);
|
|
return fileMapper.findSonPackage(fileId, authUserId, selectFor);
|
|
}
|
|
}
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson uploadDictionary(MultipartFile[] File){
|
|
|
|
+ //文件上传前的名称
|
|
|
|
+ List<String> filenames=new ArrayList<>();
|
|
|
|
+ for (MultipartFile multipartFile:File) {
|
|
|
|
+ String fileName = multipartFile.getOriginalFilename();
|
|
|
|
+ File file = new File(fileName);
|
|
|
|
+ OutputStream out = null;
|
|
|
|
+ try{
|
|
|
|
+ //获取文件流,以文件流的方式输出到新文件
|
|
|
|
+// InputStream in = multipartFile.getInputStream();
|
|
|
|
+ out = new FileOutputStream(file);
|
|
|
|
+ byte[] ss = multipartFile.getBytes();
|
|
|
|
+ for(int i = 0; i < ss.length; i++){
|
|
|
|
+ out.write(ss[i]);
|
|
|
|
+ }
|
|
|
|
+ }catch(IOException e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }finally {
|
|
|
|
+ if (out != null){
|
|
|
|
+ try {
|
|
|
|
+ out.close();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //保存文件夹及其文件
|
|
|
|
+ upload(file,filenames);
|
|
|
|
+ }
|
|
|
|
+ return ResponseJson.success();
|
|
|
|
+ }
|
|
|
|
+ public List<String> upload(File file,List<String> filenames){
|
|
|
|
+ File[] files=file.listFiles();
|
|
|
|
+ for (File f:files) {
|
|
|
|
+ if(f.isDirectory()){
|
|
|
|
+ //递归 保存文件夹(返回父id,便于确定属于哪级目录)
|
|
|
|
+ fileMapper.creatPackage(0, 0, f.getName());
|
|
|
|
+ return upload(f,filenames);
|
|
|
|
+ }else{
|
|
|
|
+ //保存文件
|
|
|
|
+ filenames.add(f.getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return filenames;
|
|
|
|
+ }
|
|
}
|
|
}
|