From f61c1902e30b0ab54e833960df7d2d79c8b62120 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Thu, 12 Oct 2023 17:11:05 +0800
Subject: [PATCH] 执行时间
---
src/main/java/com/dji/sample/media/controller/FileController.java | 46 +++++++++++++++++++++++++++++++++++++++-------
1 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/src/main/java/com/dji/sample/media/controller/FileController.java b/src/main/java/com/dji/sample/media/controller/FileController.java
index 25a6015..6b0c8e8 100644
--- a/src/main/java/com/dji/sample/media/controller/FileController.java
+++ b/src/main/java/com/dji/sample/media/controller/FileController.java
@@ -1,15 +1,17 @@
package com.dji.sample.media.controller;
+import com.dji.sample.common.model.PaginationData;
import com.dji.sample.common.model.ResponseResult;
import com.dji.sample.media.model.MediaFileDTO;
+import com.dji.sample.media.model.MediaFileEntity;
+import com.dji.sample.media.model.MediaFileQueryParam;
import com.dji.sample.media.service.IFileService;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
-import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URL;
/**
* @author sean
@@ -25,12 +27,42 @@
/**
* Get information about all the media files in this workspace based on the workspace id.
+ * 根据工作空间id获取有关此工作空间中所有媒体文件的信息。
* @param workspaceId
* @return
*/
@GetMapping("/{workspace_id}/files")
- public ResponseResult<List<MediaFileDTO>> getFilesList(@PathVariable(name = "workspace_id") String workspaceId) {
- List<MediaFileDTO> filesList = fileService.getAllFilesByWorkspaceId(workspaceId);
+ public ResponseResult<PaginationData<MediaFileDTO>> getFilesList(@RequestParam(defaultValue = "1") Long page,
+ @RequestParam(name = "page_size", defaultValue = "10") Long pageSize,
+ @PathVariable(name = "workspace_id") String workspaceId,
+ MediaFileQueryParam mediaFileQueryParam) {
+ PaginationData<MediaFileDTO> filesList = fileService.getMediaFilesPaginationByWorkspaceId(workspaceId, page, pageSize,mediaFileQueryParam);
return ResponseResult.success(filesList);
}
+
+ @GetMapping("/{workspace_id}/updateFile")
+ public ResponseResult updateFile(@PathVariable(name = "workspace_id") String workspaceId, MediaFileEntity mediaFileEntity) {
+ return ResponseResult.success(fileService.updateMediaFile(workspaceId, mediaFileEntity));
+ }
+
+
+
+ /**
+ * Query the download address of the file according to the media file id,
+ * and redirect to this address directly for download.
+ * @param workspaceId
+ * @param fileId
+ * @param response
+ */
+ @GetMapping("/{workspace_id}/file/{file_id}/url")
+ public void getFileUrl(@PathVariable(name = "workspace_id") String workspaceId,
+ @PathVariable(name = "file_id") String fileId, HttpServletResponse response) {
+
+ try {
+ URL url = fileService.getObjectUrl(workspaceId, fileId);
+ response.sendRedirect(url.toString());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}
--
Gitblit v1.9.3