|
@@ -22,7 +22,6 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
-import java.time.LocalDateTime;
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -54,7 +53,7 @@ public class FileService {
|
|
|
boolean isEmpty = file.isEmpty();
|
|
boolean isEmpty = file.isEmpty();
|
|
|
if (isEmpty) {
|
|
if (isEmpty) {
|
|
|
result.setCode(HttpStatus.GLOBAL_EXCEPTION_CODE);
|
|
result.setCode(HttpStatus.GLOBAL_EXCEPTION_CODE);
|
|
|
- result.setMsg("上传请选择文件");
|
|
|
|
|
|
|
+ result.setMsg("上传请不要选择空文件");
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
//获取文件类型
|
|
//获取文件类型
|
|
@@ -69,22 +68,29 @@ public class FileService {
|
|
|
fileInfo.setFileSuffix(FilenameUtils.getExtension(oFileName));
|
|
fileInfo.setFileSuffix(FilenameUtils.getExtension(oFileName));
|
|
|
fileInfo.setFileSize(StringUtils.isBlank(fileSize) ? new BigDecimal("0") : fileSize);
|
|
fileInfo.setFileSize(StringUtils.isBlank(fileSize) ? new BigDecimal("0") : fileSize);
|
|
|
Map<String, String> infoMap = FileUtils.uploadFileByInfo(file, FileEnum.DOCUMENT_ADDRESS);
|
|
Map<String, String> infoMap = FileUtils.uploadFileByInfo(file, FileEnum.DOCUMENT_ADDRESS);
|
|
|
- FileInfo infoDo = new FileInfo();
|
|
|
|
|
- infoDo.setId(new IdWorker(1).nextId());
|
|
|
|
|
- infoDo.setType(FileEnum.FILE_STORE_TYPE_OSS.getFileType());
|
|
|
|
|
- infoDo.setFileName(infoMap.get("fileName"));
|
|
|
|
|
- infoDo.setMd5(infoMap.get("fileMd5"));
|
|
|
|
|
- infoDo.setFilePath(infoMap.get("filePath"));
|
|
|
|
|
- infoDo.setCreateTime(LocalDateTime.now());
|
|
|
|
|
- infoDo.setUpdateTime(LocalDateTime.now());
|
|
|
|
|
-// int insert = fileInfoDao.insert(infoDo);
|
|
|
|
|
|
|
+// Map<String, String> infoMap=new HashMap<>();
|
|
|
|
|
+// infoMap.put("fileName","fileName");
|
|
|
|
|
+// infoMap.put("fileMd5","fileMd5");
|
|
|
|
|
+// infoMap.put("filePath","filePath");
|
|
|
|
|
+// infoMap.put("fileKey","fileKey");
|
|
|
|
|
+ fileInfo.setId(new IdWorker(1).nextId());
|
|
|
|
|
+ fileInfo.setType(FileEnum.FILE_STORE_TYPE_OSS.getFileType());
|
|
|
|
|
+ fileInfo.setFileName(infoMap.get("fileName"));
|
|
|
|
|
+ fileInfo.setMd5(infoMap.get("fileMd5"));
|
|
|
|
|
+ fileInfo.setFilePath(infoMap.get("filePath"));
|
|
|
|
|
+ fileInfo.setCreateTime(new Date());
|
|
|
|
|
+ fileInfo.setUpdateTime(new Date());
|
|
|
|
|
+ fileInfo.setStatus(0);
|
|
|
|
|
+ fileInfo.setDelFlag(0);
|
|
|
|
|
+ fileInfo.setCreateBy(1L);
|
|
|
|
|
+ fileInfo.setUpdateBy(1L);
|
|
|
|
|
+ fileInfoDao.insert(fileInfo);
|
|
|
//上传至oss文件地址
|
|
//上传至oss文件地址
|
|
|
if (StringUtils.isNotBlank(infoMap.get("filePath"))) {
|
|
if (StringUtils.isNotBlank(infoMap.get("filePath"))) {
|
|
|
- String oosUrl = infoMap.get("filePath");
|
|
|
|
|
result.setCode(HttpStatus.SUCCESS_CODE);
|
|
result.setCode(HttpStatus.SUCCESS_CODE);
|
|
|
result.setMsg("上传成功");
|
|
result.setMsg("上传成功");
|
|
|
Map<String, Object> map = new HashMap<>(NumberConstant.SIXTEEN);
|
|
Map<String, Object> map = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
- map.put("fileKey", infoMap.get("filePath"));
|
|
|
|
|
|
|
+ map.put("fileKey", infoMap.get("fileMd5"));
|
|
|
map.put("fileName", infoMap.get("fileName"));
|
|
map.put("fileName", infoMap.get("fileName"));
|
|
|
resultList.add(map);
|
|
resultList.add(map);
|
|
|
result.setData(resultList);
|
|
result.setData(resultList);
|