|
|
@@ -16,6 +16,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
+import org.springframework.web.multipart.MultipartRequest;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
@@ -57,7 +58,6 @@ public class SystemFileController extends BaseRESTfulController {
|
|
|
if (file != null) {
|
|
|
for (int i = 0; i < file.length; i++) {
|
|
|
try {
|
|
|
-
|
|
|
//获取系统时间
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("/yyyy/MM/dd");
|
|
|
//获取文件名
|
|
|
@@ -95,6 +95,56 @@ public class SystemFileController extends BaseRESTfulController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/insertFiles")
|
|
|
+ public RESTfulResult insertFiles(String[] fileUuids,String[] fileNames,String[]fileTypes, Map<Object,MultipartFile>FileList, MultipartRequest request) throws Exception {
|
|
|
+
|
|
|
+ List<MultipartFile> files = new ArrayList<>();
|
|
|
+ int index=-1;
|
|
|
+ for(int i=0;i<21;i++) {
|
|
|
+ MultipartFile file = request.getFile("file" + i);
|
|
|
+ if (file != null) {
|
|
|
+ files.add(file);
|
|
|
+ if (index < 0) {
|
|
|
+ index = i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < fileUuids.length; i++) {
|
|
|
+ //获取系统时间
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("/yyyy/MM/dd");
|
|
|
+ //获取文件名
|
|
|
+ String oldName = fileNames[i].toString();
|
|
|
+ //取当前时间的长整形值包含毫秒
|
|
|
+ String newName = IDutils.getImageName();
|
|
|
+ //重新命名文件
|
|
|
+
|
|
|
+ String filePath = simpleDateFormat.format(new Date())+"/"+fileTypes[i].toString();
|
|
|
+ //获取输入流
|
|
|
+ String fileTypeName = files.get(i).getOriginalFilename();
|
|
|
+ fileTypeName=fileTypeName.substring(fileTypeName.lastIndexOf(".")) ;
|
|
|
+ newName = oldName+"("+newName+")" +fileTypeName;
|
|
|
+ InputStream inputStream = files.get(i).getInputStream();
|
|
|
+ boolean result = ftpFileUtil.uploadToFtp(inputStream, filePath, newName, false);
|
|
|
+ inputStream.close();
|
|
|
+ if (result) {
|
|
|
+ SystemFile uploadFile = new SystemFile();
|
|
|
+ uploadFile.setFilename(oldName);
|
|
|
+ uploadFile.setFilepath(filePath + "/" + newName);
|
|
|
+ uploadFile.setId(fileUuids[i]);
|
|
|
+ SystemFile modela = systemFileService.add(uploadFile);
|
|
|
+ if (modela != null) {
|
|
|
+ fileUuids[i] += "," + modela.getId();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return failed(null, "上传文件失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return success();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/previewfile")
|
|
|
public RESTfulResult previewfile(@RequestBody HashMap parmas) {
|
|
|
String filename = parmas.get("filename").toString();
|