Jelajahi Sumber

添加上传文件的接口

tianboguang 2 tahun lalu
induk
melakukan
a7e0e5919e

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

@@ -1,38 +0,0 @@
-package com.fdkankan.contro.controller;
-
-
-import com.fdkankan.contro.common.Result;
-import com.fdkankan.fyun.face.FYunFileServiceInterface;
-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 javax.servlet.http.HttpServletRequest;
-
-@Log4j2
-@RestController
-@RequestMapping("/api/file/")
-public class ApiFileController {
-
-    @Autowired
-    private FYunFileServiceInterface fYunFileService;
-    /**
-     * 上传文件
-     * @param file
-     * @return
-     */
-    @RequestMapping(value = "upload", method = RequestMethod.POST)
-    public Result uploadFile(String key, @RequestParam("file") MultipartFile file) throws Exception {
-        if(ObjectUtils.isEmpty(key) || ObjectUtils.isEmpty(file)){
-            log.error("参数有误!");
-            return Result.failure("参数有误!");
-        }
-        fYunFileService.uploadFile(file.getInputStream(),key);
-        return Result.success();
-    }
-}

+ 23 - 5
src/main/java/com/fdkankan/contro/controller/SceneFileController.java

@@ -1,15 +1,15 @@
 package com.fdkankan.contro.controller;
 
+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.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.util.ObjectUtils;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
 
@@ -22,6 +22,9 @@ import java.io.IOException;
 public class SceneFileController{
 
     @Autowired
+    private FYunFileServiceInterface fYunFileService;
+
+    @Autowired
     private ISceneFileBuildService sceneFileBuildService;
 
     /**
@@ -61,4 +64,19 @@ public class SceneFileController{
     public ResultData rebuildScene(@RequestParam(value = "num") String num,@RequestParam(value = "force",defaultValue = "false") Boolean force ) throws IOException {
         return sceneFileBuildService.rebuildScene(num,force);
     }
+
+    /**
+     * 上传文件
+     * @param file
+     * @return
+     */
+    @RequestMapping(value = "upload", method = RequestMethod.POST)
+    public Result uploadFile(String key, @RequestParam("file") MultipartFile file) throws Exception {
+        if(ObjectUtils.isEmpty(key) || ObjectUtils.isEmpty(file)){
+            log.error("参数有误!");
+            return Result.failure("参数有误!");
+        }
+        fYunFileService.uploadFile(file.getInputStream(),key);
+        return Result.success();
+    }
 }