4 files modified
2 files added
| | |
| | | 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.MediaFileQueryParam; |
| | | import com.dji.sample.media.service.IFileService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | |
| | | /** |
| | | * 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) { |
| | | PaginationData<MediaFileDTO> filesList = fileService.getMediaFilesPaginationByWorkspaceId(workspaceId, page, pageSize); |
| | | @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); |
| | | } |
| | | |
| | |
| | | package com.dji.sample.media.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dji.sample.media.model.MediaFileEntity; |
| | | import com.dji.sample.media.model.MediaFileQueryParam; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * @author sean |
| | |
| | | * @date 2021/12/9 |
| | | */ |
| | | public interface IFileMapper extends BaseMapper<MediaFileEntity> { |
| | | Page<MediaFileEntity> getPage(@Param("page") Page<MediaFileEntity> mediaFileEntityPage, @Param("workspaceId") String workspaceId,@Param("query") MediaFileQueryParam mediaFileQueryParam); |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.dji.sample.media.dao.IFileMapper"> |
| | | |
| | | |
| | | <select id="getPage" resultType="com.dji.sample.media.model.MediaFileEntity"> |
| | | |
| | | SELECT * FROM media_file WHERE workspace_id = #{workspaceId} |
| | | |
| | | <if test="query.startTime !=null and query.endTime !=null"> |
| | | AND DATE_FORMAT(FROM_UNIXTIME(create_time/1000,'%Y-%m-%d'),'%Y-%m-%d') >= DATE_FORMAT(#{query.startTime},'%Y-%m-%d') |
| | | </if> |
| | | |
| | | <if test="query.endTime !=null and query.endTime !=null"> |
| | | AND DATE_FORMAT(FROM_UNIXTIME(create_time/1000,'%Y-%m-%d'),'%Y-%m-%d') <= DATE_FORMAT(#{query.endTime},'%Y-%m-%d') |
| | | </if> |
| | | |
| | | <if test="query.name !=null and query.name !=null"> |
| | | AND file_name LIKE CONCAT('%',#{query.name},'%') |
| | | </if> |
| | | |
| | | <if test="query.fileSubType != null and query.fileSubType !='' "> |
| | | AND sub_file_type in |
| | | <foreach collection="query.fileSubType.split(',')" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | |
| | | <if test="query.payload != null and query.payload !='' "> |
| | | AND sub_file_type in |
| | | <foreach collection="query.payload.split(',')" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | |
| | | </select> |
| | | </mapper> |
| New file |
| | |
| | | package com.dji.sample.media.model; |
| | | |
| | | /** |
| | | * 文件查询参数 |
| | | */ |
| | | public class MediaFileQueryParam { |
| | | /** |
| | | * 文件类型(逗号分隔字符串) |
| | | */ |
| | | private String subFileType; |
| | | |
| | | /** |
| | | * 负载类型(逗号分隔字符串) |
| | | */ |
| | | private String payload; |
| | | |
| | | /** |
| | | * 文件名 |
| | | */ |
| | | private String name; |
| | | |
| | | //开始时间 |
| | | private String startTime; |
| | | |
| | | //结束时间 |
| | | private String endTime; |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | import com.dji.sample.common.model.PaginationData; |
| | | import com.dji.sample.media.model.FileUploadDTO; |
| | | import com.dji.sample.media.model.MediaFileDTO; |
| | | import com.dji.sample.media.model.MediaFileQueryParam; |
| | | |
| | | import java.net.URL; |
| | | import java.util.List; |
| | |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | PaginationData<MediaFileDTO> getMediaFilesPaginationByWorkspaceId(String workspaceId, long page, long pageSize); |
| | | PaginationData<MediaFileDTO> getMediaFilesPaginationByWorkspaceId(String workspaceId, long page, long pageSize, MediaFileQueryParam mediaFileQueryParam); |
| | | |
| | | /** |
| | | * Get the download address of the file. |
| | |
| | | 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 com.dji.sample.wayline.model.entity.WaylineJobEntity; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public PaginationData<MediaFileDTO> getMediaFilesPaginationByWorkspaceId(String workspaceId, long page, long pageSize) { |
| | | Page<MediaFileEntity> pageData = mapper.selectPage( |
| | | new Page<MediaFileEntity>(page, pageSize), |
| | | new LambdaQueryWrapper<MediaFileEntity>() |
| | | .eq(MediaFileEntity::getWorkspaceId, workspaceId) |
| | | .orderByDesc(MediaFileEntity::getId)); |
| | | public PaginationData<MediaFileDTO> getMediaFilesPaginationByWorkspaceId(String workspaceId, long page, long pageSize, MediaFileQueryParam mediaFileQueryParam) { |
| | | // Page<MediaFileEntity> pageData = mapper.selectPage( |
| | | // new Page<MediaFileEntity>(page, pageSize), |
| | | // new LambdaQueryWrapper<MediaFileEntity>() |
| | | // .eq(MediaFileEntity::getWorkspaceId, workspaceId) |
| | | // .orderByDesc(MediaFileEntity::getId)); |
| | | |
| | | Page<MediaFileEntity> pageData = mapper.getPage(new Page<MediaFileEntity>(page, pageSize),workspaceId,mediaFileQueryParam); |
| | | |
| | | List<MediaFileDTO> records = pageData.getRecords() |
| | | .stream() |
| | | .map(this::entityConvertToDto) |