瀏覽代碼

修改文件上传逻辑

tianboguang 2 年之前
父節點
當前提交
c7ab937287

+ 41 - 0
src/main/java/com/fdkankan/contro/controller/ApiFileController.java

@@ -0,0 +1,41 @@
+package com.fdkankan.contro.controller;
+
+
+import com.fdkankan.common.constant.ErrorCode;
+import com.fdkankan.common.exception.BusinessException;
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
+import com.fdkankan.web.response.ResultData;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.ObjectUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+
+@Log4j2
+@RestController
+@RequestMapping("/api/file/")
+public class ApiFileController {
+
+    @Autowired
+    private FYunFileServiceInterface fYunFileService;
+
+    /**
+     * 上传文件
+     * @param file
+     * @return
+     */
+    @RequestMapping(value = "upload", method = RequestMethod.POST)
+    public ResultData uploadFile(String key, @RequestParam("file") MultipartFile file) throws Exception {
+        if(ObjectUtils.isEmpty(key) || ObjectUtils.isEmpty(file)){
+            log.error("参数有误!");
+            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
+        }
+        fYunFileService.uploadFile(file.getInputStream(),key.concat(File.separator).concat(file.getOriginalFilename()));
+        return ResultData.ok();
+    }
+}

+ 1 - 25
src/main/java/com/fdkankan/contro/controller/SceneFileController.java

@@ -1,20 +1,12 @@
 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;
-import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.web.response.ResultData;
 import lombok.extern.log4j.Log4j2;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.ObjectUtils;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
 
-import java.io.File;
 import java.io.IOException;
 
 /**
@@ -26,9 +18,6 @@ import java.io.IOException;
 public class SceneFileController{
 
     @Autowired
-    private FYunFileServiceInterface fYunFileService;
-
-    @Autowired
     private ISceneFileBuildService sceneFileBuildService;
 
     /**
@@ -69,18 +58,5 @@ public class SceneFileController{
         return sceneFileBuildService.rebuildScene(num,force);
     }
 
-    /**
-     * 上传文件
-     * @param file
-     * @return
-     */
-    @RequestMapping(value = "upload", method = RequestMethod.POST)
-    public ResultData uploadFile(String key, @RequestParam("file") MultipartFile file) throws Exception {
-        if(ObjectUtils.isEmpty(key) || ObjectUtils.isEmpty(file)){
-            log.error("参数有误!");
-            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
-        }
-        fYunFileService.uploadFile(file.getInputStream(),key.concat(File.separator).concat(file.getOriginalFilename()));
-        return ResultData.ok();
-    }
+
 }