|
@@ -1,5 +1,6 @@
|
|
|
package com.dk.mdm.controller;
|
|
package com.dk.mdm.controller;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.dk.common.infrastructure.enums.ErrorCodeEnum;
|
|
import com.dk.common.infrastructure.enums.ErrorCodeEnum;
|
|
|
import com.dk.common.response.ResponseResultUtil;
|
|
import com.dk.common.response.ResponseResultUtil;
|
|
|
import com.dk.common.response.ResponseResultVO;
|
|
import com.dk.common.response.ResponseResultVO;
|
|
@@ -10,6 +11,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@@ -26,7 +28,7 @@ public class FileController {
|
|
|
*/
|
|
*/
|
|
|
@ApiOperation(value = "上传文件", notes = "上传文件")
|
|
@ApiOperation(value = "上传文件", notes = "上传文件")
|
|
|
@PostMapping("upload")
|
|
@PostMapping("upload")
|
|
|
- public ResponseResultVO<String> upload(@RequestPart("file") MultipartFile file, @RequestParam("folder") String folder) {
|
|
|
|
|
|
|
+ public ResponseResultVO<?> upload(@RequestPart("file") MultipartFile file, @RequestParam("folder") String folder) {
|
|
|
if (file.isEmpty()) {
|
|
if (file.isEmpty()) {
|
|
|
return ResponseResultUtil.error(ErrorCodeEnum.FILE_UPLOAD_FAIL.getCode(), ErrorCodeEnum.FILE_UPLOAD_FAIL.getMessage());
|
|
return ResponseResultUtil.error(ErrorCodeEnum.FILE_UPLOAD_FAIL.getCode(), ErrorCodeEnum.FILE_UPLOAD_FAIL.getMessage());
|
|
|
}
|
|
}
|
|
@@ -39,7 +41,12 @@ public class FileController {
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
file.transferTo(dest);
|
|
file.transferTo(dest);
|
|
|
- return ResponseResultUtil.success(filePath.replace(uploadPath, ""));
|
|
|
|
|
|
|
+ //组装参数后返回
|
|
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
|
|
+ json.put("path", filePath.replace(uploadPath, ""));
|
|
|
|
|
+ json.put("name", fileName);
|
|
|
|
|
+ json.put("createTime", LocalDate.now());
|
|
|
|
|
+ return ResponseResultUtil.success(json);
|
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|