| | |
| | | package com.dji.sample.media.controller; |
| | | |
| | | import com.dji.sample.common.model.CustomClaim; |
| | | import com.dji.sample.common.model.PaginationData; |
| | | import com.dji.sample.common.model.ResponseResult; |
| | | import com.dji.sample.media.model.FileUploadDTO; |
| | | 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.apache.ibatis.annotations.Update; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import java.io.IOException; |
| | | import java.net.URL; |
| | | import java.util.List; |
| | | |
| | | import static com.dji.sample.component.AuthInterceptor.TOKEN_CLAIM; |
| | | |
| | | /** |
| | | * @author sean |
| | |
| | | /** |
| | | * 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<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); |
| | | public ResponseResult<PaginationData<MediaFileEntity>> getFilesList(@RequestParam(defaultValue = "1") Long page, |
| | | @RequestParam(name = "page_size", defaultValue = "10") Long pageSize, |
| | | @PathVariable(name = "workspace_id") String workspaceId, |
| | | MediaFileQueryParam mediaFileQueryParam) { |
| | | PaginationData<MediaFileEntity> 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) { |
| | | @GetMapping("/listAdded") |
| | | public ResponseResult listIsadd() { |
| | | List<MediaFileEntity> entityList = fileService.listByIsadd(); |
| | | return ResponseResult.success(entityList); |
| | | } |
| | | |
| | | @PutMapping("/examine") |
| | | public ResponseResult examineData(@RequestParam String fileId) { |
| | | int is = fileService.updateExamByFileId(fileId); |
| | | if (is != 0) { |
| | | return ResponseResult.success(); |
| | | } else { |
| | | return ResponseResult.error("更新状态失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | | @GetMapping("/{workspace_id}/files/{job_id}") |
| | | public ResponseResult findFilesList(@PathVariable(name = "workspace_id") String workspaceId, @PathVariable(name = "job_id") String jobId) { |
| | | return ResponseResult.success(fileService.listMediaFileEntity(workspaceId, jobId)); |
| | | } |
| | | |
| | | @PostMapping("/{workspace_id}/updateFile") |
| | | public ResponseResult updateFile(HttpServletRequest request, @PathVariable(name = "workspace_id") String workspaceId, @RequestBody MediaFileEntity mediaFileEntity) { |
| | | CustomClaim claims = (CustomClaim) request.getAttribute(TOKEN_CLAIM); |
| | | mediaFileEntity.setUserId(claims.getId()); |
| | | return ResponseResult.success(fileService.updateMediaFile(workspaceId, mediaFileEntity)); |
| | | } |
| | | |
| | | @DeleteMapping("/{workspace_id}/deleteFile") |
| | | |
| | | public ResponseResult deleteFile(@PathVariable(name = "workspace_id") String workspaceId, @RequestParam String fileId) { |
| | | int count = fileService.deleteMedia(workspaceId, fileId); |
| | | if (count == 0) { |
| | | return ResponseResult.error("删除失败"); |
| | | } |
| | | return ResponseResult.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 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 |