mirror of https://gitee.com/stylefeng/roses
【8.0.2】【file】更新获取antdv详情的批量接口
parent
4390a3b1c9
commit
1acc50200e
|
@ -29,6 +29,7 @@ import cn.stylefeng.roses.kernel.file.api.pojo.request.SysFileInfoRequest;
|
|||
import cn.stylefeng.roses.kernel.file.api.pojo.response.SysFileInfoResponse;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 获取文件信息的api
|
||||
|
@ -87,6 +88,14 @@ public interface FileInfoApi {
|
|||
*/
|
||||
AntdvFileInfo buildAntdvFileInfo(Long fileId);
|
||||
|
||||
/**
|
||||
* 通过文件id集合,批量获取文件信息详情
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/11/2 9:48
|
||||
*/
|
||||
List<AntdvFileInfo> buildAntdvFileInfoBatch(List<Long> fileIdList);
|
||||
|
||||
/**
|
||||
* 真实删除文件
|
||||
*
|
||||
|
|
|
@ -30,7 +30,9 @@ import lombok.Data;
|
|||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件信息表
|
||||
|
@ -122,6 +124,13 @@ public class SysFileInfoRequest extends BaseRequest {
|
|||
@ChineseDescription("存储路径")
|
||||
private String filePath;
|
||||
|
||||
/**
|
||||
* 文件ID集合,用在批量获取文件信息详情
|
||||
*/
|
||||
@NotEmpty(message = "文件id集合不能为空", groups = batchGetFileAntdvInfo.class)
|
||||
@ChineseDescription("文件id集合")
|
||||
private List<Long> fileIdList;
|
||||
|
||||
/**
|
||||
* 版本回退
|
||||
*/
|
||||
|
@ -134,4 +143,10 @@ public class SysFileInfoRequest extends BaseRequest {
|
|||
public @interface previewByObjectName {
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量获取文件信息详情
|
||||
*/
|
||||
public @interface batchGetFileAntdvInfo {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -290,4 +290,16 @@ public class SysFileInfoController {
|
|||
return new SuccessResponseData<>(fileInfoApi.buildAntdvFileInfo(sysFileInfoRequest.getFileId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过文件id集合,批量获取文件信息详情
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/11/2 9:45
|
||||
*/
|
||||
@GetResource(name = "通过文件id集合,批量获取文件信息详情", path = "/sysFileInfo/getAntdVInfoBatch")
|
||||
public ResponseData<List<AntdvFileInfo>> getAntdVInfoBatch(
|
||||
@Validated(SysFileInfoRequest.batchGetFileAntdvInfo.class) SysFileInfoRequest sysFileInfoRequest) {
|
||||
return new SuccessResponseData<>(fileInfoApi.buildAntdvFileInfoBatch(sysFileInfoRequest.getFileIdList()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ import javax.annotation.Resource;
|
|||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -278,8 +279,8 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
|
|||
List<SysFileInfo> records = page.getRecords();
|
||||
|
||||
// 排除defaultAvatar.png这个图片,这个是默认头像
|
||||
List<SysFileInfo> newList = records.stream()
|
||||
.filter(i -> !i.getFileOriginName().equals(FileConstants.DEFAULT_AVATAR_FILE_OBJ_NAME)).collect(Collectors.toList());
|
||||
List<SysFileInfo> newList = records.stream().filter(i -> !i.getFileOriginName().equals(FileConstants.DEFAULT_AVATAR_FILE_OBJ_NAME))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 拼接图片url地址
|
||||
for (SysFileInfo sysFileInfo : newList) {
|
||||
|
@ -532,6 +533,38 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
|
|||
return antdvFileInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AntdvFileInfo> buildAntdvFileInfoBatch(List<Long> fileIdList) {
|
||||
if (ObjectUtil.isEmpty(fileIdList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<AntdvFileInfo> antdvFileInfos = new ArrayList<>();
|
||||
for (Long fileId : fileIdList) {
|
||||
AntdvFileInfo antdvFileInfo = new AntdvFileInfo();
|
||||
|
||||
// 设置唯一id
|
||||
antdvFileInfo.setUid(IdWorker.getIdStr());
|
||||
|
||||
// 设置文件名称
|
||||
LambdaQueryWrapper<SysFileInfo> sysFileInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sysFileInfoLambdaQueryWrapper.eq(SysFileInfo::getFileId, fileId);
|
||||
sysFileInfoLambdaQueryWrapper.select(SysFileInfo::getFileOriginName);
|
||||
SysFileInfo sysFileInfo = this.getOne(sysFileInfoLambdaQueryWrapper);
|
||||
if (sysFileInfo == null) {
|
||||
continue;
|
||||
}
|
||||
antdvFileInfo.setName(sysFileInfo.getFileOriginName());
|
||||
|
||||
// 设置文件的访问url
|
||||
String fileAuthUrl = this.getFileAuthUrl(fileId);
|
||||
antdvFileInfo.setThumbUrl(fileAuthUrl);
|
||||
antdvFileInfos.add(antdvFileInfo);
|
||||
}
|
||||
|
||||
return antdvFileInfos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFile(Long fileId) {
|
||||
SysFileInfoRequest sysFileInfoRequest = new SysFileInfoRequest();
|
||||
|
|
Loading…
Reference in New Issue