feat:(REQ-3540) 上传文件加上文件大小/创建人/更新人
This commit is contained in:
parent
480abec0c9
commit
cfffd2889a
@ -23,6 +23,12 @@ public abstract class CommonConstants {
|
||||
*/
|
||||
public static final String APP_PRO_BUCKET_NAME = "axzo-pro";
|
||||
|
||||
/**
|
||||
* 文件存储B
|
||||
* 字节(Byte,简称 B)
|
||||
*/
|
||||
public static final String DEFAULT_FILE_STORAGE_UNIT = "B";
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
|
||||
@ -70,4 +70,27 @@ public class ApiSignUrlUploadRequest {
|
||||
* 文件key
|
||||
*/
|
||||
private String fileKey;
|
||||
|
||||
|
||||
/**
|
||||
* 存储单位
|
||||
*/
|
||||
private String storageUnit;
|
||||
|
||||
/**
|
||||
* 文件大小-单位B
|
||||
* 字节(Byte,简称 B)
|
||||
*/
|
||||
private Integer fileSize;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
}
|
||||
|
||||
@ -72,4 +72,24 @@ public class SignUrlUploadDto {
|
||||
* 文件key
|
||||
*/
|
||||
private String fileKey;
|
||||
|
||||
/**
|
||||
* 存储单位
|
||||
*/
|
||||
private String storageUnit;
|
||||
|
||||
/**
|
||||
* 文件大小-单位KB
|
||||
*/
|
||||
private Integer fileSize;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package cn.axzo.oss.service.metafile.impl;
|
||||
|
||||
import cn.axzo.oss.common.constans.CommonConstants;
|
||||
import cn.axzo.oss.common.enums.FileStatusEnum;
|
||||
import cn.axzo.oss.common.utils.UrlUtil;
|
||||
import cn.axzo.oss.common.utils.Utility;
|
||||
@ -52,7 +53,7 @@ public class HandleFileService extends WithFileService{
|
||||
, Objects.isNull(dto.getHasFileName()) ? true: dto.getHasFileName() );
|
||||
//2 保存File对象
|
||||
this.saveOssFile(fileUploadConfig, dto.getFileName(), fileFormat, uuid,
|
||||
signUrlUpload.getDownloadSignUrl(), Utility.getMd5(signUrlUpload.getDownloadSignUrl()), expiration);
|
||||
signUrlUpload.getDownloadSignUrl(), Utility.getMd5(signUrlUpload.getDownloadSignUrl()), expiration, dto);
|
||||
return SignUrlUploadResponse.builder()
|
||||
.signUrl(UrlUtil.httpToHttps(signUrlUpload.getSignUrl()))
|
||||
.fileKey(uuid)
|
||||
@ -71,7 +72,7 @@ public class HandleFileService extends WithFileService{
|
||||
|
||||
|
||||
private File saveOssFile(FileUploadConfig fileUploadConfig, String fileName, String fileConform, String uuid,
|
||||
String fileUrl, String fileMd5, Long expiration) {
|
||||
String fileUrl, String fileMd5, Long expiration,SignUrlUploadDto dto) {
|
||||
File byFileUuid = this.fileDao.getByFileUuid(uuid);
|
||||
if (Objects.isNull(byFileUuid) || Objects.isNull(byFileUuid.getId())) {
|
||||
File ossFile = new File();
|
||||
@ -81,8 +82,8 @@ public class HandleFileService extends WithFileService{
|
||||
ossFile.setBucketName(fileUploadConfig.getBucketName());
|
||||
ossFile.setDirectory(fileUploadConfig.getDirectory());
|
||||
ossFile.setStatus(FileStatusEnum.STATUS_UPLOAD_FAIL.getCode());
|
||||
ossFile.setStorageUnit(fileUploadConfig.getStorageUnit());
|
||||
ossFile.setStorageSize(fileUploadConfig.getStorageSize());
|
||||
ossFile.setStorageUnit(StringUtils.isNotBlank(dto.getStorageUnit()) ? dto.getStorageUnit() : CommonConstants.DEFAULT_FILE_STORAGE_UNIT);
|
||||
ossFile.setStorageSize(Objects.nonNull(dto.getFileSize()) ? dto.getFileSize() : 0);
|
||||
ossFile.setFileFormat(fileConform);
|
||||
ossFile.setFileUuid(uuid);
|
||||
ossFile.setFileUrl(fileUrl);
|
||||
@ -90,8 +91,13 @@ public class HandleFileService extends WithFileService{
|
||||
ossFile.setStatus(FileStatusEnum.STATUS_UPLOAD_SUCCESS.getCode());
|
||||
ossFile.setFileName(fileName);
|
||||
ossFile.setFileMd5(fileMd5);
|
||||
ossFile.setCreateBy(dto.getCreateBy());
|
||||
ossFile.setUpdateBy(dto.getUpdateBy());
|
||||
fileDao.save(ossFile);
|
||||
return ossFile;
|
||||
} else {
|
||||
byFileUuid.setUpdateBy(dto.getUpdateBy());
|
||||
fileDao.saveOrUpdate(byFileUuid);
|
||||
}
|
||||
return byFileUuid;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user