feat:(REQ-3540) 根据fileKey获取文件基础信息

This commit is contained in:
xudawei 2025-04-07 14:56:22 +08:00
parent 8b18471de8
commit 480abec0c9
6 changed files with 181 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import cn.axzo.core.utils.converter.BeanConverter;
import cn.axzo.framework.auth.domain.ContextInfo;
import cn.axzo.oss.client.convert.ServerFileConvert;
import cn.axzo.oss.common.utils.BeanConvertUtil;
import cn.axzo.oss.dal.entity.File;
import cn.axzo.oss.http.api.ServerFileServiceApi;
import cn.axzo.oss.http.model.ApiSignUrlDownloadRequest;
import cn.axzo.oss.http.model.ApiSignUrlDownloadResponse;
@ -32,6 +33,8 @@ import cn.axzo.oss.http.model.copyobject.ServerFileBatchCopyObjectRequest;
import cn.axzo.oss.http.model.copyobject.ServerFileBatchCopyObjectResponse;
import cn.axzo.oss.http.model.copyobject.ServerFileBatchDeleteObjectRequest;
import cn.axzo.oss.http.model.copyobject.ServerFileBatchDeleteObjectResponse;
import cn.axzo.oss.http.model.file.FetchFileInfoRequest;
import cn.axzo.oss.http.model.file.FetchFileInfoResponse;
import cn.axzo.oss.http.model.file.FileRenameRequest;
import cn.axzo.oss.http.model.file.FileRenameResponse;
import cn.axzo.oss.http.model.file.UpdateFileInfoRequest;
@ -59,6 +62,8 @@ import cn.hutool.json.JSONUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@ -310,4 +315,16 @@ public class ServerFileController implements ServerFileServiceApi {
AssertUtil.isFalse(CollectionUtils.isEmpty(deleteObjectFileDtos), "参数为空");
return DeleteObjectsFileDto.builder().deleteFiles(deleteObjectFileDtos).build();
}
/**
* 获取文件信息
*/
@Override
public CommonResponse<FetchFileInfoResponse> fetchFileInfo(@Valid @RequestBody FetchFileInfoRequest request) {
File file = fileService.fetchFileInfo(request.getFileKey());
if (Objects.isNull(file) || Objects.isNull(file.getId())) {
return CommonResponse.success();
}
return CommonResponse.success(BeanUtil.copyProperties(file, FetchFileInfoResponse.class));
}
}

View File

@ -26,6 +26,8 @@ import cn.axzo.oss.http.model.copyobject.ServerFileBatchCopyObjectRequest;
import cn.axzo.oss.http.model.copyobject.ServerFileBatchCopyObjectResponse;
import cn.axzo.oss.http.model.copyobject.ServerFileBatchDeleteObjectRequest;
import cn.axzo.oss.http.model.copyobject.ServerFileBatchDeleteObjectResponse;
import cn.axzo.oss.http.model.file.FetchFileInfoRequest;
import cn.axzo.oss.http.model.file.FetchFileInfoResponse;
import cn.axzo.oss.http.model.file.FileRenameRequest;
import cn.axzo.oss.http.model.file.FileRenameResponse;
import cn.axzo.oss.http.model.file.UpdateFileInfoRequest;
@ -167,5 +169,11 @@ public interface ServerFileServiceApi {
@RequestMapping(value = "/api/server/deleteObject", method = RequestMethod.POST)
CommonResponse<ServerFileBatchDeleteObjectResponse> batchDeleteObject(@Valid @RequestBody ServerFileBatchDeleteObjectRequest request);
/**
* 获取文件信息
*/
@RequestMapping(value = "/api/server/fetchFileInfo", method = RequestMethod.POST)
CommonResponse<FetchFileInfoResponse> fetchFileInfo(@Valid @RequestBody FetchFileInfoRequest request);
}

View File

@ -0,0 +1,28 @@
package cn.axzo.oss.http.model.file;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 获取文件请求
*
* @author xudawei
* @date 2025-03-12
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class FetchFileInfoRequest {
/**
* 文件Id
*/
private Long fileId;
/**
* 文件fileKey
*/
private String fileKey;
}

View File

@ -0,0 +1,115 @@
package cn.axzo.oss.http.model.file;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* 获取文件返回
*
* @author xudawei
* @date 2025-03-12
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class FetchFileInfoResponse {
private Long id;
/**
* APP渠道桶编码
*/
private String appChannelBucketNo;
/**
* 应用编码
*/
private String appCode;
/**
* 渠道代码
*/
private String channelCode;
/**
* 桶名称
*/
private String bucketName;
/**
* 上传目录
*/
private String directory;
/**
* 文件UUID
*/
private String fileUuid;
/**
* 文件md5
*/
private String fileMd5;
/**
* 文件地址
*/
private String fileUrl;
/**
* 文件URLmd5
*/
private String urlMd5;
/**
* 文件上传状态:(0:处理中,1:上传成功,2:上传失败,3:已删除)
*/
private Integer status;
/**
* 文件类型
*/
private String fileFormat;
/**
* 原文件名称
*/
private String fileName;
/**
* 存储大小限制单位KB/MB
*/
private String storageUnit;
/**
* 存储大小
*/
private Integer storageSize;
/**
* 创建时间
*/
private Date createAt;
/**
* 更新时间
*/
private Date updateAt;
/**
* 创建人
*/
private String createBy;
/**
* 更新人
*/
private String updateBy;
}

View File

@ -2,6 +2,7 @@ package cn.axzo.oss.service.api;
import cn.axzo.framework.auth.domain.ContextInfo;
import cn.axzo.oss.dal.entity.AppChannelBucket;
import cn.axzo.oss.dal.entity.File;
import cn.axzo.oss.dal.entity.FileUploadConfig;
import cn.axzo.oss.manager.api.dto.request.AppInfoDto;
import cn.axzo.oss.manager.api.dto.request.DeleteFileDto;
@ -139,4 +140,9 @@ public interface FileService {
* 删除文件信息
*/
void deleteObject(DeleteObjectsFileDto dto);
/**
* 获取文件基础信息
*/
File fetchFileInfo(String fileKey);
}

View File

@ -1510,4 +1510,11 @@ public class FileServiceImpl implements FileService {
File file = byFileUuids.get(0);
return Pair.of(deleteObjectFileDtos, file);
}
/**
* 获取文件基础信息
*/
public File fetchFileInfo(String fileKey) {
return this.fileDao.getByFileUuid(fileKey);
}
}