浏览代码

修改文件上传逻辑

tianboguang 2 年之前
父节点
当前提交
3e595d11e1
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      src/main/java/com/fdkankan/contro/controller/SceneFileController.java

+ 6 - 3
src/main/java/com/fdkankan/contro/controller/SceneFileController.java

@@ -1,5 +1,8 @@
 package com.fdkankan.contro.controller;
 
+import com.fdkankan.common.constant.ErrorCode;
+import com.fdkankan.common.constant.ServerCode;
+import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.contro.common.Result;
 import com.fdkankan.contro.service.ISceneFileBuildService;
 import com.fdkankan.contro.vo.ResponseSceneFile;
@@ -72,12 +75,12 @@ public class SceneFileController{
      * @return
      */
     @RequestMapping(value = "upload", method = RequestMethod.POST)
-    public Result uploadFile(String key, @RequestParam("file") MultipartFile file) throws Exception {
+    public ResultData uploadFile(String key, @RequestParam("file") MultipartFile file) throws Exception {
         if(ObjectUtils.isEmpty(key) || ObjectUtils.isEmpty(file)){
             log.error("参数有误!");
-            return Result.failure("参数有误!");
+            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
         }
         fYunFileService.uploadFile(file.getInputStream(),key.concat(File.separator).concat(file.getOriginalFilename()));
-        return Result.success();
+        return ResultData.ok();
     }
 }