Browse Source

file api修改

yingp 7 years ago
parent
commit
27a5798db4

+ 89 - 1
base-servers/file/file-api/src/main/java/com/usoftchina/saas/file/api/FileApi.java

@@ -13,6 +13,8 @@ import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.util.List;
+
 /**
  * 文件接口
  *
@@ -37,7 +39,7 @@ public interface FileApi {
      * @return
      */
     @PostMapping(value = "/folder")
-    Result<FolderDTO> folder(FolderSaveDTO newFolder);
+    Result<FolderDTO> createFolder(FolderSaveDTO newFolder);
 
     /**
      * 根据id查看文件详情
@@ -48,6 +50,24 @@ public interface FileApi {
     @GetMapping(value = "/info/{id}")
     Result<FileInfoDTO> getFileInfo(@PathVariable(value = "id") Long id);
 
+    /**
+     * 根据path查看文件信息
+     *
+     * @param path
+     * @return
+     */
+    @GetMapping(value = "/info")
+    Result<FileInfoDTO> getFileInfoByPath(@RequestParam String path);
+
+    /**
+     * 查看子文件
+     *
+     * @param folderId
+     * @return
+     */
+    @GetMapping(value = "/list")
+    Result<List<FileInfoDTO>> listFiles(Long folderId);
+
     /**
      * 上传文件到指定文件夹
      *
@@ -58,4 +78,72 @@ public interface FileApi {
      */
     @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
     Result<FileInfoDTO> upload(Long folderId, @RequestPart(value = "file") MultipartFile file) throws Exception;
+
+    /**
+     * 文件下载
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping(value = "/download/{id}")
+    byte[] download(@PathVariable Long id);
+
+    /**
+     * 文件下载
+     *
+     * @param path
+     * @return
+     */
+    @GetMapping(value = "/download")
+    byte[] downloadByPath(@RequestParam String path);
+
+    /**
+     * 删除文件
+     *
+     * @param id
+     * @param purge true表示直接删除,false表示放入回收站
+     * @return
+     */
+    @GetMapping(value = "/delete/{id}")
+    Result delete(@PathVariable Long id,
+                  @RequestParam(required = false, defaultValue = "false") Boolean purge);
+
+    /**
+     * 删除文件
+     *
+     * @param id
+     * @param purge true表示直接删除,false表示放入回收站
+     * @return
+     */
+    @GetMapping(value = "/delete")
+    Result deleteByPath(@PathVariable Long id,
+                  @RequestParam(required = false, defaultValue = "false") Boolean purge);
+
+    /**
+     * 还原文件
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping(value = "/restore/{id}")
+    Result restore(@PathVariable Long id);
+
+    /**
+     * 还原文件
+     *
+     * @param path
+     * @return
+     */
+    @GetMapping(value = "/restore")
+    Result restoreByPath(@RequestParam String path);
+
+    /**
+     * 移动文件到文件夹
+     *
+     * @param fileId
+     * @param folderId
+     * @return
+     */
+    @GetMapping(value = "/move")
+    Result move(@RequestParam Long fileId, @RequestParam Long folderId);
 }

+ 1 - 1
base-servers/file/file-server/src/main/java/com/usoftchina/saas/file/controller/FileController.java

@@ -82,7 +82,7 @@ public class FileController {
 
     @ApiOperation(value = "创建文件夹")
     @PostMapping(value = "/folder")
-    public Result<FolderDTO> folder(FolderSaveDTO newFolder) {
+    public Result<FolderDTO> createFolder(FolderSaveDTO newFolder) {
         BizAssert.notNull(newFolder.getName(), ExceptionCode.FOLDER_NAME_EMPTY);
         // 检查父文件夹
         FileInfo parent = checkFolder(newFolder.getFolderId());