Commit 6bd35351 authored by coderTomato's avatar coderTomato

修改前端上传失败的返回值

parent 2494d9b9
...@@ -10,7 +10,6 @@ import com.dlink.service.CatalogueService; ...@@ -10,7 +10,6 @@ import com.dlink.service.CatalogueService;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.*; import java.io.*;
...@@ -31,18 +30,15 @@ public class CatalogueController { ...@@ -31,18 +30,15 @@ public class CatalogueController {
@Autowired @Autowired
private CatalogueService catalogueService; private CatalogueService catalogueService;
@Value("${dlink.uploadpath}")
private String uploadpath;
@PostMapping("/upload/{id}") @PostMapping("/upload/{id}")
public Result<String> upload(MultipartFile file,@PathVariable Integer id) { public Result<String> upload(MultipartFile file,@PathVariable Integer id) {
//获取上传的路径 //获取上传的路径
String filePath = uploadpath; String filePath = System.getProperty("user.dir");
//获取源文件的名称 //获取源文件的名称
String fileName = file.getOriginalFilename(); String fileName = file.getOriginalFilename();
String zipPath = filePath+fileName; String zipPath = filePath+File.separator+fileName;
String unzipFileName = fileName.substring(0,fileName.lastIndexOf(".")); String unzipFileName = fileName.substring(0,fileName.lastIndexOf("."));
String unzipPath = filePath+unzipFileName; String unzipPath = filePath+File.separator+unzipFileName;
File unzipFile = new File(unzipPath); File unzipFile = new File(unzipPath);
File zipFile = new File(zipPath); File zipFile = new File(zipPath);
if(unzipFile.exists()){ if(unzipFile.exists()){
......
...@@ -23,7 +23,7 @@ const UploadModal:React.FC<UploadModalProps> = (props:any) => { ...@@ -23,7 +23,7 @@ const UploadModal:React.FC<UploadModalProps> = (props:any) => {
} }
if (info.file.status === 'done') { if (info.file.status === 'done') {
console.log('info:',info); console.log('info:',info);
if(info.file.response.code == "-1"){ if(info.file.response.code === 1){
message.error(`${info.file.response.msg} `); message.error(`${info.file.response.msg} `);
}else{ }else{
message.success(`${info.file.name} file uploaded successfully`); message.success(`${info.file.name} file uploaded successfully`);
......
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