feat(代码优化): 获取文件列表接口开发
This commit is contained in:
parent
fd071a63a9
commit
0721af05ed
@ -3,7 +3,7 @@ package com.qiwenshare.file.api;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qiwenshare.file.domain.UserFile;
|
||||
import com.qiwenshare.file.vo.file.FileListVo;
|
||||
import com.qiwenshare.file.vo.file.FileListVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@ -12,11 +12,11 @@ public interface IUserFileService extends IService<UserFile> {
|
||||
List<UserFile> selectUserFileByNameAndPath(String fileName, String filePath, Long userId);
|
||||
List<UserFile> selectSameUserFile(String fileName, String filePath, String extendName, Long userId);
|
||||
|
||||
IPage<FileListVo> userFileList(Long userId, String filePath, Long beginCount, Long pageCount);
|
||||
IPage<FileListVO> userFileList(Long userId, String filePath, Long beginCount, Long pageCount);
|
||||
void updateFilepathByUserFileId(String userFileId, String newfilePath, long userId);
|
||||
void userFileCopy(String userFileId, String newfilePath, long userId);
|
||||
|
||||
IPage<FileListVo> getFileByFileType(Integer fileTypeId, Long currentPage, Long pageCount, long userId);
|
||||
IPage<FileListVO> getFileByFileType(Integer fileTypeId, Long currentPage, Long pageCount, long userId);
|
||||
List<UserFile> selectUserFileListByPath(String filePath, Long userId);
|
||||
List<UserFile> selectFilePathTreeByUserId(Long userId);
|
||||
void deleteUserFile(String userFileId, Long sessionUserId);
|
||||
|
@ -17,7 +17,7 @@ import com.qiwenshare.file.dto.commonfile.CommonFileDTO;
|
||||
import com.qiwenshare.file.io.QiwenFile;
|
||||
import com.qiwenshare.file.vo.commonfile.CommonFileListVo;
|
||||
import com.qiwenshare.file.vo.commonfile.CommonFileUser;
|
||||
import com.qiwenshare.file.vo.file.FileListVo;
|
||||
import com.qiwenshare.file.vo.file.FileListVO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -93,7 +93,7 @@ public class CommonFileController {
|
||||
@Operation(summary = "获取共享空间中某个用户的文件列表", description = "用来做前台列表展示", tags = {"file"})
|
||||
@RequestMapping(value = "/commonFileList", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public RestResult<FileListVo> commonFileList(
|
||||
public RestResult<FileListVO> commonFileList(
|
||||
@Parameter(description = "用户id", required = true) Long commonFileId,
|
||||
@Parameter(description = "文件路径", required = true) String filePath,
|
||||
@Parameter(description = "当前页", required = true) long currentPage,
|
||||
@ -102,7 +102,7 @@ public class CommonFileController {
|
||||
CommonFile commonFile = commonFileService.getById(commonFileId);
|
||||
UserFile userFile = userFileService.getById(commonFile.getUserFileId());
|
||||
QiwenFile qiwenFile = new QiwenFile(userFile.getFilePath(), filePath, true);
|
||||
IPage<FileListVo> fileList = userFileService.userFileList(userFile.getUserId(), qiwenFile.getPath(), currentPage, pageCount);
|
||||
IPage<FileListVO> fileList = userFileService.userFileList(userFile.getUserId(), qiwenFile.getPath(), currentPage, pageCount);
|
||||
|
||||
return RestResult.success().data(fileList);
|
||||
|
||||
|
@ -28,7 +28,7 @@ import com.qiwenshare.file.util.QiwenFileUtil;
|
||||
import com.qiwenshare.file.util.RestResult2;
|
||||
import com.qiwenshare.file.util.TreeNode;
|
||||
import com.qiwenshare.file.vo.file.FileDetailVO;
|
||||
import com.qiwenshare.file.vo.file.FileListVo;
|
||||
import com.qiwenshare.file.vo.file.FileListVO;
|
||||
import com.qiwenshare.file.vo.file.SearchFileVO;
|
||||
import com.qiwenshare.ufop.factory.UFOPFactory;
|
||||
import com.qiwenshare.ufop.operation.copy.Copier;
|
||||
@ -38,6 +38,7 @@ import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -264,18 +265,21 @@ public class FileController {
|
||||
@Operation(summary = "获取文件列表", description = "用来做前台列表展示", tags = {"file"})
|
||||
@RequestMapping(value = "/getfilelist", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public RestResult2 getFileList(
|
||||
public RestResult2<FileListVO> getFileList(
|
||||
@Parameter(description = "文件类型", required = true) String fileType,
|
||||
@Parameter(description = "文件路径", required = true) String filePath,
|
||||
@Parameter(description = "当前页", required = true) long currentPage,
|
||||
@Parameter(description = "页面数量", required = true) long pageCount){
|
||||
|
||||
|
||||
IPage<FileListVo> fileList = userFileService.userFileList(null, filePath, currentPage, pageCount);
|
||||
|
||||
return RestResult2.success().dataList(fileList.getRecords(), fileList.getTotal());
|
||||
|
||||
if ("0".equals(fileType)) {
|
||||
IPage<FileListVO> fileList = userFileService.userFileList(null, filePath, currentPage, pageCount);
|
||||
return RestResult2.success().dataList(fileList.getRecords(), fileList.getTotal());
|
||||
} else {
|
||||
IPage<FileListVO> fileList = userFileService.getFileByFileType(Integer.valueOf(fileType), currentPage, pageCount, SessionUtil.getSession().getUserId());
|
||||
return RestResult2.success().dataList(fileList.getRecords(), fileList.getTotal());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "批量删除文件", description = "批量删除文件", tags = {"file"})
|
||||
@RequestMapping(value = "/batchdeletefile", method = RequestMethod.POST)
|
||||
@MyLog(operation = "批量删除文件", module = CURRENT_MODULE)
|
||||
@ -404,25 +408,6 @@ public class FileController {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Operation(summary = "通过文件类型选择文件", description = "该接口可以实现文件格式分类查看", tags = {"file"})
|
||||
@RequestMapping(value = "/selectfilebyfiletype", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public RestResult2<FileListVo> selectFileByFileType(@Parameter(description = "文件类型", required = true) int fileType,
|
||||
@Parameter(description = "当前页", required = true) @RequestParam(defaultValue = "1") long currentPage,
|
||||
@Parameter(description = "页面数量", required = true) @RequestParam(defaultValue = "10") long pageCount) {
|
||||
|
||||
JwtUser sessionUserBean = SessionUtil.getSession();
|
||||
|
||||
long userId = sessionUserBean.getUserId();
|
||||
|
||||
IPage<FileListVo> result = userFileService.getFileByFileType(fileType, currentPage, pageCount, userId);
|
||||
|
||||
return RestResult2.success().dataList(result.getRecords(), result.getTotal());
|
||||
|
||||
}
|
||||
|
||||
@Operation(summary = "获取文件树", description = "文件移动的时候需要用到该接口,用来展示目录树", tags = {"file"})
|
||||
@RequestMapping(value = "/getfiletree", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
|
@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qiwenshare.file.domain.CommonFile;
|
||||
import com.qiwenshare.file.vo.commonfile.CommonFileListVo;
|
||||
import com.qiwenshare.file.vo.commonfile.CommonFileUser;
|
||||
import com.qiwenshare.file.vo.file.FileListVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.qiwenshare.file.domain.UserFile;
|
||||
import com.qiwenshare.file.vo.file.FileListVo;
|
||||
import com.qiwenshare.file.vo.file.FileListVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@ -16,6 +16,6 @@ public interface UserFileMapper extends BaseMapper<UserFile> {
|
||||
|
||||
List<UserFile> selectUserFileByLikeRightFilePath(@Param("filePath") String filePath, @Param("userId") long userId);
|
||||
|
||||
IPage<FileListVo> selectPageVo(Page<?> page, @Param("userFile") UserFile userFile, @Param("fileTypeId") Integer fileTypeId);
|
||||
IPage<FileListVO> selectPageVo(Page<?> page, @Param("userFile") UserFile userFile, @Param("fileTypeId") Integer fileTypeId);
|
||||
Long selectStorageSizeByUserId(@Param("userId") Long userId);
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import com.qiwenshare.file.domain.CommonFile;
|
||||
import com.qiwenshare.file.mapper.CommonFileMapper;
|
||||
import com.qiwenshare.file.vo.commonfile.CommonFileListVo;
|
||||
import com.qiwenshare.file.vo.commonfile.CommonFileUser;
|
||||
import com.qiwenshare.file.vo.file.FileListVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -19,7 +19,7 @@ import com.qiwenshare.file.domain.UserFile;
|
||||
import com.qiwenshare.file.io.QiwenFile;
|
||||
import com.qiwenshare.file.mapper.RecoveryFileMapper;
|
||||
import com.qiwenshare.file.mapper.UserFileMapper;
|
||||
import com.qiwenshare.file.vo.file.FileListVo;
|
||||
import com.qiwenshare.file.vo.file.FileListVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -68,8 +68,8 @@ public class UserFileService extends ServiceImpl<UserFileMapper, UserFile> imple
|
||||
|
||||
|
||||
@Override
|
||||
public IPage<FileListVo> userFileList(Long userId, String filePath, Long currentPage, Long pageCount) {
|
||||
Page<FileListVo> page = new Page<>(currentPage, pageCount);
|
||||
public IPage<FileListVO> userFileList(Long userId, String filePath, Long currentPage, Long pageCount) {
|
||||
Page<FileListVO> page = new Page<>(currentPage, pageCount);
|
||||
UserFile userFile = new UserFile();
|
||||
JwtUser sessionUserBean = SessionUtil.getSession();
|
||||
if (userId == null) {
|
||||
@ -165,8 +165,8 @@ public class UserFileService extends ServiceImpl<UserFileMapper, UserFile> imple
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<FileListVo> getFileByFileType(Integer fileTypeId, Long currentPage, Long pageCount, long userId) {
|
||||
Page<FileListVo> page = new Page<>(currentPage, pageCount);
|
||||
public IPage<FileListVO> getFileByFileType(Integer fileTypeId, Long currentPage, Long pageCount, long userId) {
|
||||
Page<FileListVO> page = new Page<>(currentPage, pageCount);
|
||||
|
||||
UserFile userFile = new UserFile();
|
||||
userFile.setUserId(userId);
|
||||
|
@ -4,7 +4,7 @@ import com.qiwenshare.file.domain.Music;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FileListVo {
|
||||
public class FileListVO {
|
||||
private String fileId;
|
||||
|
||||
private String timeStampName;
|
@ -6,7 +6,7 @@
|
||||
|
||||
<mapper namespace="com.qiwenshare.file.mapper.UserFileMapper">
|
||||
|
||||
<select id="selectPageVo" parameterType="com.qiwenshare.file.domain.UserFile" resultType="com.qiwenshare.file.vo.file.FileListVo">
|
||||
<select id="selectPageVo" parameterType="com.qiwenshare.file.domain.UserFile" resultType="com.qiwenshare.file.vo.file.FileListVO">
|
||||
select * from userfile a
|
||||
left join image on a.fileId = image.fileId
|
||||
left join file on file.fileId = a.fileId
|
||||
|
Loading…
Reference in New Issue
Block a user