From e21fe957e156bd5c3207c6a5be1c955ff0194d24 Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期五, 24 四月 2026 18:24:01 +0800
Subject: [PATCH] APK文件上传
---
src/main/java/com/ruoyi/basic/utils/FileUtil.java | 383 +++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 261 insertions(+), 122 deletions(-)
diff --git a/src/main/java/com/ruoyi/basic/utils/FileUtil.java b/src/main/java/com/ruoyi/basic/utils/FileUtil.java
index 1e629cf..d964efc 100644
--- a/src/main/java/com/ruoyi/basic/utils/FileUtil.java
+++ b/src/main/java/com/ruoyi/basic/utils/FileUtil.java
@@ -2,12 +2,15 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.ruoyi.basic.constant.ApplicationType;
-import com.ruoyi.basic.constant.RecordType;
-import com.ruoyi.basic.dto.StorageAttachmentDTO;
+import com.ruoyi.basic.dto.StorageAttachmentVO;
+import com.ruoyi.basic.dto.StorageBlobDTO;
import com.ruoyi.basic.dto.StorageBlobVO;
+import com.ruoyi.basic.enums.ApplicationTypeEnum;
+import com.ruoyi.basic.enums.RecordTypeEnum;
import com.ruoyi.basic.mapper.StorageAttachmentMapper;
+import com.ruoyi.basic.mapper.StorageBlobMapper;
import com.ruoyi.basic.pojo.StorageAttachment;
+import com.ruoyi.basic.pojo.StorageBlob;
import com.ruoyi.common.config.FileProperties;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.security.Keys;
@@ -34,6 +37,7 @@
private final FileProperties properties;
private final StorageAttachmentMapper storageAttachmentMapper;
private final StringRedisTemplate stringRedisTemplate;
+ private final StorageBlobMapper storageBlobMapper;
private static final String TOKEN_USAGE_KEY_PREFIX = "file:token:usage:";
private static final DateTimeFormatter YEAR_PATH_FORMATTER = DateTimeFormatter.ofPattern("yyyy");
@@ -45,16 +49,16 @@
* @param application 鏂囦欢鐢ㄩ��
* @param recordType 鍏宠仈璁板綍绫诲瀷
* @param recordId 鍏宠仈璁板綍id
- * @param storageBlobVOS 鏂囦欢淇℃伅
+ * @param storageBlobDTOS 鏂囦欢淇℃伅
*/
- public void saveStorageAttachment(ApplicationType application, RecordType recordType, Long recordId, List<StorageBlobVO> storageBlobVOS) {
- if (CollectionUtils.isEmpty(storageBlobVOS)) {
+ public void saveStorageAttachment(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId, List<StorageBlobDTO> storageBlobDTOS) {
+ if (CollectionUtils.isEmpty(storageBlobDTOS)) {
throw new RuntimeException("鏂囦欢淇℃伅涓嶈兘涓虹┖");
}
- if (!application.isValid()) {
+ if (application == null) {
throw new RuntimeException("鏂囦欢鐢ㄩ�斾笉鑳戒负绌�");
}
- if (!recordType.isValid()) {
+ if (recordType == null) {
throw new RuntimeException("鍏宠仈璁板綍绫诲瀷涓嶈兘涓虹┖");
}
if (recordId == null || recordId <= 0) {
@@ -63,16 +67,16 @@
// 鍒犻櫎鏃ч檮浠朵俊鎭�
deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordId(application, recordType, recordId);
List<StorageAttachment> storageAttachments = new ArrayList<>();
- for (StorageBlobVO storageBlobVO : storageBlobVOS) {
+ for (StorageBlobDTO storageBlobDTO : storageBlobDTOS) {
StorageAttachment storageAttachment = new StorageAttachment();
storageAttachment.setApplication(application.getType());
storageAttachment.setRecordType(recordType.getType());
storageAttachment.setRecordId(recordId);
- storageAttachment.setStorageBlobId(storageBlobVO.getId());
+ storageAttachment.setStorageBlobId(storageBlobDTO.getId());
storageAttachment.setDeleted(0L);
+ storageAttachments.add(storageAttachment);
}
- // todo fileChange
-// storageAttachmentMapper.insert(storageAttachments);
+ storageAttachmentMapper.insert(storageAttachments);
}
/**
@@ -81,8 +85,7 @@
* @param storageBlobIds 鏂囦欢id
*/
public void deleteStorageBlobs(List<Long> storageBlobIds) {
- // todo fileChange
-// storageBlobMapper.deleteByIds(storageBlobIds);
+ storageBlobMapper.deleteByIds(storageBlobIds);
}
/**
@@ -91,10 +94,9 @@
* @param storageAttachmentIds 鏂囦欢id
*/
public void deleteStorageBlobsByStorageAttachmentIds(List<Long> storageAttachmentIds) {
- // todo fileChange
-// List<StorageAttachment> storageAttachments = storageAttachmentMapper.selectByIds(storageAttachmentIds);
-// List<Long> storageBlobIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId).collect(Collectors.toList());
-// deleteStorageBlobs(storageBlobIds);
+ List<StorageAttachment> storageAttachments = storageAttachmentMapper.selectByIds(storageAttachmentIds);
+ List<Long> storageBlobIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId).collect(Collectors.toList());
+ deleteStorageBlobs(storageBlobIds);
}
/**
@@ -102,21 +104,21 @@
*
* @param application 鏂囦欢鐢ㄩ��
* @param recordType 鍏宠仈璁板綍绫诲瀷
- * @param recordId 鍏宠仈璁板綍id
+ * @param recordIds 鍏宠仈璁板綍id
*/
- public void deleteStorageBlobsByApplicationAndRecordTypeAndRecordId(ApplicationType application, RecordType recordType, Long recordId) {
- if (!application.isValid()) {
+ public void deleteStorageBlobsByApplicationAndRecordTypeAndRecordIds(ApplicationTypeEnum application, RecordTypeEnum recordType, List<Long> recordIds) {
+ if (recordIds == null || recordIds.isEmpty()) {
+ throw new RuntimeException("鍏宠仈璁板綍id涓嶈兘涓虹┖");
+ }
+ if (application == null) {
throw new RuntimeException("鏂囦欢鐢ㄩ�斾笉鑳戒负绌�");
}
- if (!recordType.isValid()) {
+ if (recordType == null) {
throw new RuntimeException("鍏宠仈璁板綍绫诲瀷涓嶈兘涓虹┖");
- }
- if (recordId == null || recordId <= 0) {
- throw new RuntimeException("鍏宠仈璁板綍id涓嶈兘涓虹┖");
}
List<StorageAttachment> storageAttachments = storageAttachmentMapper.selectList(new LambdaQueryWrapper<StorageAttachment>()
.eq(StorageAttachment::getRecordType, recordType.getType())
- .eq(StorageAttachment::getRecordId, recordId)
+ .in(StorageAttachment::getRecordId, recordIds)
.eq(StorageAttachment::getApplication, application.getType()));
if (CollectionUtils.isNotEmpty(storageAttachments)) {
List<Long> storageAttachmentIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId)
@@ -132,21 +134,27 @@
*/
public void deleteStorageAttachmentsByStorageAttachmentIds(List<Long> storageAttachmentIds) {
deleteStorageBlobsByStorageAttachmentIds(storageAttachmentIds);
- // todo fileChange
-// storageAttachmentMapper.deleteByIds(storageAttachmentIds);
+ storageAttachmentMapper.deleteByIds(storageAttachmentIds);
}
- public void deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordId(ApplicationType application, RecordType recordType, Long recordId) {
- if (!application.isValid()) {
- throw new RuntimeException("鏂囦欢鐢ㄩ�斾笉鑳戒负绌�");
- }
- if (!recordType.isValid()) {
- throw new RuntimeException("鍏宠仈璁板綍绫诲瀷涓嶈兘涓虹┖");
- }
+ /**
+ * 鍒犻櫎鏂囦欢鍏宠仈淇℃伅
+ *
+ * @param application 鏂囦欢鐢ㄩ��
+ * @param recordType 鍏宠仈璁板綍绫诲瀷
+ * @param recordId 鍏宠仈璁板綍id
+ */
+ public void deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId) {
if (recordId == null || recordId <= 0) {
throw new RuntimeException("鍏宠仈璁板綍id涓嶈兘涓虹┖");
}
- deleteStorageBlobsByApplicationAndRecordTypeAndRecordId(application, recordType, recordId);
+ if (application == null) {
+ throw new RuntimeException("鏂囦欢鐢ㄩ�斾笉鑳戒负绌�");
+ }
+ if (recordType == null) {
+ throw new RuntimeException("鍏宠仈璁板綍绫诲瀷涓嶈兘涓虹┖");
+ }
+ deleteStorageBlobsByApplicationAndRecordTypeAndRecordIds(application, recordType, Arrays.asList(recordId));
storageAttachmentMapper.delete(new LambdaQueryWrapper<StorageAttachment>()
.eq(StorageAttachment::getRecordType, recordType.getType())
.eq(StorageAttachment::getRecordId, recordId)
@@ -154,7 +162,31 @@
}
/**
- * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢淇℃伅
+ * 鎵归噺鍒犻櫎鏂囦欢鍏宠仈淇℃伅 attachment
+ *
+ * @param application 鏂囦欢鐢ㄩ��
+ * @param recordType 鍏宠仈璁板綍绫诲瀷
+ * @param recordIds 鍏宠仈璁板綍id
+ */
+ public void deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordIds(ApplicationTypeEnum application, RecordTypeEnum recordType, List<Long> recordIds) {
+ if (recordIds == null || recordIds.isEmpty()) {
+ throw new RuntimeException("鍏宠仈璁板綍id涓嶈兘涓虹┖");
+ }
+ if (application == null) {
+ throw new RuntimeException("鏂囦欢鐢ㄩ�斾笉鑳戒负绌�");
+ }
+ if (recordType == null) {
+ throw new RuntimeException("鍏宠仈璁板綍绫诲瀷涓嶈兘涓虹┖");
+ }
+ deleteStorageBlobsByApplicationAndRecordTypeAndRecordIds(application, recordType, recordIds);
+ storageAttachmentMapper.delete(new LambdaQueryWrapper<StorageAttachment>()
+ .eq(StorageAttachment::getRecordType, recordType.getType())
+ .in(StorageAttachment::getRecordId, recordIds)
+ .eq(StorageAttachment::getApplication, application.getType()));
+ }
+
+ /**
+ * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢淇℃伅 attachment
*
* @param storageAttachmentIds 鏂囦欢id
*/
@@ -162,27 +194,24 @@
if (CollectionUtils.isEmpty(storageAttachmentIds)) {
throw new RuntimeException("鏂囦欢id涓嶈兘涓虹┖");
}
- // todo fileChange
-// return storageAttachmentMapper.selectByIds(storageAttachmentIds);
- return new ArrayList<>();
+ return storageAttachmentMapper.selectByIds(storageAttachmentIds);
}
/**
- * 閫氳繃鏂囦欢鐢ㄩ�斻�佸叧鑱旇褰曠被鍨嬨�佸叧鑱旇褰昳d鑾峰彇鏂囦欢鍏宠仈淇℃伅
+ * 閫氳繃鏂囦欢鐢ㄩ�斻�佸叧鑱旇褰曠被鍨嬨�佸叧鑱旇褰昳d鑾峰彇鏂囦欢鍏宠仈淇℃伅 attachment
*
* @param application 鏂囦欢鐢ㄩ��
* @param recordType 鍏宠仈璁板綍绫诲瀷
* @param recordId 鍏宠仈璁板綍id
*/
- public List<StorageAttachment> getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(ApplicationType application, RecordType recordType, Long recordId) {
- if (!application.isValid()) {
- throw new RuntimeException("鏂囦欢鐢ㄩ�斾笉鑳戒负绌�");
- }
- if (!recordType.isValid()) {
- throw new RuntimeException("鍏宠仈璁板綍绫诲瀷涓嶈兘涓虹┖");
- }
+ public List<StorageAttachment> getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId) {
if (recordId == null || recordId <= 0) {
throw new RuntimeException("鍏宠仈璁板綍id涓嶈兘涓虹┖");
+ } if (application == null) {
+ throw new RuntimeException("鏂囦欢鐢ㄩ�斾笉鑳戒负绌�");
+ }
+ if (recordType == null) {
+ throw new RuntimeException("鍏宠仈璁板綍绫诲瀷涓嶈兘涓虹┖");
}
return storageAttachmentMapper.selectList(new LambdaQueryWrapper<StorageAttachment>()
.eq(StorageAttachment::getRecordType, recordType.getType())
@@ -191,159 +220,207 @@
}
/**
- * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢淇℃伅
+ * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢淇℃伅 blob
*
* @param storageAttachmentIds 鏂囦欢id
*/
- public List<StorageBlobVO> getStorageBlobDTOsByStorageAttachmentIds(List<Long> storageAttachmentIds) {
+ public List<StorageBlobVO> getStorageBlobVOsByStorageAttachmentIds(List<Long> storageAttachmentIds) {
List<StorageAttachment> storageAttachments = getStorageAttachmentsByStorageAttachmentIds(storageAttachmentIds);
if (CollectionUtils.isEmpty(storageAttachments)) {
return null;
}
List<Long> storageBlobIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId).collect(Collectors.toList());
- // todo fileChange
-// List<StorageBlob> storageBlobs = storageBlobMapper.selectByIds(storageBlobIds);
-// List<StorageBlobDTO> storageBlobDTOS = new ArrayList<>();
-// for (StorageBlob storageBlob : storageBlobs) {
-// StorageBlobDTO storageBlobDTO = new StorageBlobDTO();
-// BeanUtils.copyProperties(storageBlob, storageBlobDTO);
-// storageBlobDTO.setPreviewURL(buildSignedPreviewUrl(storageBlobDTO));
-// storageBlobDTO.setDownloadURL(buildSignedDownloadUrl(storageBlobDTO));
-// storageBlobDTOS.add(storageBlobDTO);
-// }
- return new ArrayList<>();
+ List<StorageBlob> storageBlobs = storageBlobMapper.selectByIds(storageBlobIds);
+ List<StorageBlobVO> storageBlobDTOS = new ArrayList<>();
+ for (StorageBlob storageBlob : storageBlobs) {
+ StorageBlobVO storageBlobVO = new StorageBlobVO();
+ BeanUtils.copyProperties(storageBlob, storageBlobVO);
+ storageBlobVO.setPreviewURL(buildSignedPreviewUrl(storageBlobVO));
+ storageBlobVO.setDownloadURL(buildSignedDownloadUrl(storageBlobVO));
+ storageBlobDTOS.add(storageBlobVO);
+ }
+ return storageBlobDTOS;
}
/**
- * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢淇℃伅瀛樺湪杩囨湡鏃堕棿
+ * 閫氳繃鏂囦欢鐢ㄩ�斻�佸叧鑱旇褰曠被鍨嬨�佸叧鑱旇褰昳d鑾峰彇鏂囦欢淇℃伅 blob
+ *
+ * @param application 鏂囦欢鐢ㄩ��
+ * @param recordType 鍏宠仈璁板綍绫诲瀷
+ * @param recordId 鍏宠仈璁板綍id
+ */
+ public List<StorageBlobVO> getStorageBlobVOsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId) {
+ List<StorageAttachment> storageAttachments = getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(application, recordType, recordId);
+ if (CollectionUtils.isEmpty(storageAttachments)) {
+ return null;
+ }
+ List<Long> storageBlobIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId).collect(Collectors.toList());
+ List<StorageBlob> storageBlobs = storageBlobMapper.selectByIds(storageBlobIds);
+ List<StorageBlobVO> storageBlobDTOS = new ArrayList<>();
+ for (StorageBlob storageBlob : storageBlobs) {
+ StorageBlobVO storageBlobVO = new StorageBlobVO();
+ BeanUtils.copyProperties(storageBlob, storageBlobVO);
+ storageBlobVO.setPreviewURL(buildSignedPreviewUrl(storageBlobVO));
+ storageBlobVO.setDownloadURL(buildSignedDownloadUrl(storageBlobVO));
+ storageBlobDTOS.add(storageBlobVO);
+ }
+ return storageBlobDTOS;
+ }
+
+ /**
+ * 閫氳繃鏂囦欢鐢ㄩ�斻�佸叧鑱旇褰曠被鍨嬨�佸叧鑱旇褰昳d鑾峰彇鏂囦欢淇℃伅 鑷畾涔夎繃鏈熸椂闂达紙鍒嗛挓锛� blob
+ *
+ * @param application 鏂囦欢鐢ㄩ��
+ * @param recordType 鍏宠仈璁板綍绫诲瀷
+ * @param recordId 鍏宠仈璁板綍id
+ * @param expired 杩囨湡鏃堕棿
+ */
+ public List<StorageBlobVO> getStorageBlobVOsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId, BigDecimal expired) {
+ List<StorageAttachment> storageAttachments = getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(application, recordType, recordId);
+ if (CollectionUtils.isEmpty(storageAttachments)) {
+ return null;
+ }
+ List<Long> storageBlobIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId).collect(Collectors.toList());
+ List<StorageBlob> storageBlobs = storageBlobMapper.selectByIds(storageBlobIds);
+ List<StorageBlobVO> storageBlobDTOS = new ArrayList<>();
+ for (StorageBlob storageBlob : storageBlobs) {
+ StorageBlobVO storageBlobVO = new StorageBlobVO();
+ BeanUtils.copyProperties(storageBlob, storageBlobVO);
+ storageBlobVO.setPreviewURL(buildSignedUrl(storageBlobVO, "/preview/", expired));
+ storageBlobVO.setDownloadURL(buildSignedUrl(storageBlobVO, "/download/", expired));
+ storageBlobDTOS.add(storageBlobVO);
+ }
+ return storageBlobDTOS;
+ }
+
+ /**
+ * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢淇℃伅瀛樺湪杩囨湡鏃堕棿 鑷畾涔夎繃鏈熸椂闂达紙鍒嗛挓锛� blob
*
* @param storageAttachmentIds 鏂囦欢id
* @param expired 杩囨湡鏃堕棿
*/
- public List<StorageBlobVO> getStorageBlobDTOsByStorageAttachmentIds(List<Long> storageAttachmentIds, BigDecimal expired) {
+ public List<StorageBlobVO> getStorageBlobVOsByStorageAttachmentIds(List<Long> storageAttachmentIds, BigDecimal expired) {
List<StorageAttachment> storageAttachments = getStorageAttachmentsByStorageAttachmentIds(storageAttachmentIds);
if (CollectionUtils.isEmpty(storageAttachments)) {
return null;
}
List<Long> storageBlobIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId).collect(Collectors.toList());
- // todo fileChange
-// List<StorageBlob> storageBlobs = storageBlobMapper.selectByIds(storageBlobIds);
-// List<StorageBlobDTO> storageBlobDTOS = new ArrayList<>();
-// for (StorageBlob storageBlob : storageBlobs) {
-// StorageBlobDTO storageBlobDTO = new StorageBlobDTO();
-// BeanUtils.copyProperties(storageBlob, storageBlobDTO);
-// storageBlobDTO.setPreviewURL(buildSignedUrl(storageBlobDTO, "/preview/", expired));
-// storageBlobDTO.setDownloadURL(buildSignedUrl(storageBlobDTO, "/download/", expired));
-// storageBlobDTOS.add(storageBlobDTO);
-// }
-// return storageBlobDTOS;
- return new ArrayList<>();
+ List<StorageBlob> storageBlobs = storageBlobMapper.selectByIds(storageBlobIds);
+ List<StorageBlobVO> storageBlobDTOS = new ArrayList<>();
+ for (StorageBlob storageBlob : storageBlobs) {
+ StorageBlobVO storageBlobVO = new StorageBlobVO();
+ BeanUtils.copyProperties(storageBlob, storageBlobVO);
+ storageBlobVO.setPreviewURL(buildSignedUrl(storageBlobVO, "/preview/", expired));
+ storageBlobVO.setDownloadURL(buildSignedUrl(storageBlobVO, "/download/", expired));
+ storageBlobDTOS.add(storageBlobVO);
+ }
+ return storageBlobDTOS;
}
/**
- * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢淇℃伅
+ * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢淇℃伅 attachment
*
* @param storageAttachmentIds 鏂囦欢id
*/
- public List<StorageAttachmentDTO> getStorageAttachmentDTOsByStorageAttachmentIds(List<Long> storageAttachmentIds) {
+ public List<StorageAttachmentVO> getStorageAttachmentVOSByStorageAttachmentIds(List<Long> storageAttachmentIds) {
List<StorageAttachment> storageAttachments = getStorageAttachmentsByStorageAttachmentIds(storageAttachmentIds);
if (CollectionUtils.isEmpty(storageAttachments)) {
return new ArrayList<>();
}
- List<StorageAttachmentDTO> storageAttachmentDTOS = new ArrayList<>();
+ List<StorageAttachmentVO> storageAttachmentVOS = new ArrayList<>();
for (StorageAttachment storageAttachment : storageAttachments) {
- StorageAttachmentDTO storageAttachmentDTO = new StorageAttachmentDTO();
- BeanUtils.copyProperties(storageAttachment, storageAttachmentDTO);
- List<StorageBlobVO> storageBlobVOS = getStorageBlobDTOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()));
+ StorageAttachmentVO storageAttachmentVO = new StorageAttachmentVO();
+ BeanUtils.copyProperties(storageAttachment, storageAttachmentVO);
+ List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()));
if (CollectionUtils.isEmpty(storageBlobVOS)) {
- storageAttachmentDTO.setStorageBlobVOS(new ArrayList<>());
+ storageAttachmentVO.setStorageBlobVOS(new ArrayList<>());
} else {
- storageAttachmentDTO.setStorageBlobVOS(storageBlobVOS);
+ storageAttachmentVO.setStorageBlobVOS(storageBlobVOS);
}
- storageAttachmentDTOS.add(storageAttachmentDTO);
+ storageAttachmentVOS.add(storageAttachmentVO);
}
- return storageAttachmentDTOS;
+ return storageAttachmentVOS;
}
/**
- * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢淇℃伅瀛樺湪杩囨湡鏃堕棿
+ * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢淇℃伅瀛樺湪杩囨湡鏃堕棿 鑷畾涔夎繃鏈熸椂闂达紙鍒嗛挓锛� attachment
*
* @param storageAttachmentIds 鏂囦欢id
* @param expired 杩囨湡鏃堕棿
*/
- public List<StorageAttachmentDTO> getStorageAttachmentDTOsByStorageAttachmentIds(List<Long> storageAttachmentIds, BigDecimal expired) {
+ public List<StorageAttachmentVO> getStorageAttachmentVOSByStorageAttachmentIds(List<Long> storageAttachmentIds, BigDecimal expired) {
List<StorageAttachment> storageAttachments = getStorageAttachmentsByStorageAttachmentIds(storageAttachmentIds);
if (CollectionUtils.isEmpty(storageAttachments)) {
return new ArrayList<>();
}
- List<StorageAttachmentDTO> storageAttachmentDTOS = new ArrayList<>();
+ List<StorageAttachmentVO> storageAttachmentVOS = new ArrayList<>();
for (StorageAttachment storageAttachment : storageAttachments) {
- StorageAttachmentDTO storageAttachmentDTO = new StorageAttachmentDTO();
- BeanUtils.copyProperties(storageAttachment, storageAttachmentDTO);
- List<StorageBlobVO> storageBlobVOS = getStorageBlobDTOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()), expired);
+ StorageAttachmentVO storageAttachmentVO = new StorageAttachmentVO();
+ BeanUtils.copyProperties(storageAttachment, storageAttachmentVO);
+ List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()), expired);
if (CollectionUtils.isEmpty(storageBlobVOS)) {
- storageAttachmentDTO.setStorageBlobVOS(new ArrayList<>());
+ storageAttachmentVO.setStorageBlobVOS(new ArrayList<>());
} else {
- storageAttachmentDTO.setStorageBlobVOS(storageBlobVOS);
+ storageAttachmentVO.setStorageBlobVOS(storageBlobVOS);
}
- storageAttachmentDTOS.add(storageAttachmentDTO);
+ storageAttachmentVOS.add(storageAttachmentVO);
}
- return storageAttachmentDTOS;
+ return storageAttachmentVOS;
}
/**
- * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢淇℃伅
+ * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢淇℃伅 attachment
*
* @param application 搴旂敤
* @param recordType 璁板綍绫诲瀷
* @param recordId 璁板綍id
*/
- public List<StorageAttachmentDTO> getStorageAttachmentDTOsByApplicationAndRecordTypeAndRecordId(ApplicationType application, RecordType recordType, Long recordId) {
+ public List<StorageAttachmentVO> getStorageAttachmentVOSByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId) {
List<StorageAttachment> storageAttachments = getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(application, recordType, recordId);
if (CollectionUtils.isEmpty(storageAttachments)) {
return new ArrayList<>();
}
- List<StorageAttachmentDTO> storageAttachmentDTOS = new ArrayList<>();
+ List<StorageAttachmentVO> storageAttachmentVOS = new ArrayList<>();
for (StorageAttachment storageAttachment : storageAttachments) {
- StorageAttachmentDTO storageAttachmentDTO = new StorageAttachmentDTO();
- BeanUtils.copyProperties(storageAttachment, storageAttachmentDTO);
- List<StorageBlobVO> storageBlobVOS = getStorageBlobDTOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()));
+ StorageAttachmentVO storageAttachmentVO = new StorageAttachmentVO();
+ BeanUtils.copyProperties(storageAttachment, storageAttachmentVO);
+ List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()));
if (CollectionUtils.isEmpty(storageBlobVOS)) {
- storageAttachmentDTO.setStorageBlobVOS(new ArrayList<>());
+ storageAttachmentVO.setStorageBlobVOS(new ArrayList<>());
} else {
- storageAttachmentDTO.setStorageBlobVOS(storageBlobVOS);
+ storageAttachmentVO.setStorageBlobVOS(storageBlobVOS);
}
- storageAttachmentDTOS.add(storageAttachmentDTO);
+ storageAttachmentVOS.add(storageAttachmentVO);
}
- return storageAttachmentDTOS;
+ return storageAttachmentVOS;
}
/**
- * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢淇℃伅瀛樺湪杩囨湡鏃堕棿
+ * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢淇℃伅瀛樺湪杩囨湡鏃堕棿 鑷畾涔夎繃鏈熸椂闂达紙鍒嗛挓锛� attachment
*
* @param application 搴旂敤
* @param recordType 璁板綍绫诲瀷
* @param recordId 璁板綍id
* @param expired 杩囨湡鏃堕棿
*/
- public List<StorageAttachmentDTO> getStorageAttachmentDTOsByApplicationAndRecordTypeAndRecordId(ApplicationType application, RecordType recordType, Long recordId, BigDecimal expired) {
+ public List<StorageAttachmentVO> getStorageAttachmentVOSByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId, BigDecimal expired) {
List<StorageAttachment> storageAttachments = getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(application, recordType, recordId);
if (CollectionUtils.isEmpty(storageAttachments)) {
return new ArrayList<>();
}
- List<StorageAttachmentDTO> storageAttachmentDTOS = new ArrayList<>();
+ List<StorageAttachmentVO> storageAttachmentVOS = new ArrayList<>();
for (StorageAttachment storageAttachment : storageAttachments) {
- StorageAttachmentDTO storageAttachmentDTO = new StorageAttachmentDTO();
- BeanUtils.copyProperties(storageAttachment, storageAttachmentDTO);
- List<StorageBlobVO> storageBlobVOS = getStorageBlobDTOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()), expired);
+ StorageAttachmentVO storageAttachmentVO = new StorageAttachmentVO();
+ BeanUtils.copyProperties(storageAttachment, storageAttachmentVO);
+ List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()), expired);
if (CollectionUtils.isEmpty(storageBlobVOS)) {
- storageAttachmentDTO.setStorageBlobVOS(new ArrayList<>());
+ storageAttachmentVO.setStorageBlobVOS(new ArrayList<>());
} else {
- storageAttachmentDTO.setStorageBlobVOS(storageBlobVOS);
+ storageAttachmentVO.setStorageBlobVOS(storageBlobVOS);
}
- storageAttachmentDTOS.add(storageAttachmentDTO);
+ storageAttachmentVOS.add(storageAttachmentVO);
}
- return storageAttachmentDTOS;
+ return storageAttachmentVOS;
}
/**
@@ -353,7 +430,7 @@
*/
public List<String> getFilePreviewURLByStorageAttachmentIds(List<Long> storageAttachmentIds) {
List<String> res = new ArrayList<>();
- List<StorageBlobVO> storageBlobVOS = getStorageBlobDTOsByStorageAttachmentIds(storageAttachmentIds);
+ List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(storageAttachmentIds);
for (StorageBlobVO storageBlobVO : storageBlobVOS) {
res.add(buildSignedPreviewUrl(storageBlobVO));
}
@@ -361,14 +438,14 @@
}
/**
- * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢棰勮鍦板潃瀛樺湪杩囨湡鏃堕棿
+ * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢棰勮鍦板潃瀛樺湪杩囨湡鏃堕棿 鑷畾涔夎繃鏈熸椂闂达紙鍒嗛挓锛�
*
* @param storageAttachmentIds 鏂囦欢鍏宠仈id
* @param expired 杩囨湡鏃堕棿
*/
public List<String> getFilePreviewURLByStorageAttachmentIds(List<Long> storageAttachmentIds, BigDecimal expired) {
List<String> res = new ArrayList<>();
- List<StorageBlobVO> storageBlobVOS = getStorageBlobDTOsByStorageAttachmentIds(storageAttachmentIds);
+ List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(storageAttachmentIds);
for (StorageBlobVO storageBlobVO : storageBlobVOS) {
res.add(buildSignedUrl(storageBlobVO, "/preview/", expired));
}
@@ -382,7 +459,7 @@
*/
public List<String> getFileDownloadURLByStorageAttachmentIds(List<Long> storageAttachmentIds) {
List<String> res = new ArrayList<>();
- List<StorageBlobVO> storageBlobVOS = getStorageBlobDTOsByStorageAttachmentIds(storageAttachmentIds);
+ List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(storageAttachmentIds);
for (StorageBlobVO storageBlobVO : storageBlobVOS) {
res.add(buildSignedDownloadUrl(storageBlobVO));
}
@@ -390,18 +467,80 @@
}
/**
- * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢涓嬭浇鍦板潃瀛樺湪杩囨湡鏃堕棿
+ * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢涓嬭浇鍦板潃瀛樺湪杩囨湡鏃堕棿 鑷畾涔夎繃鏈熸椂闂达紙鍒嗛挓锛�
*
* @param storageAttachmentIds 鏂囦欢鍏宠仈id
* @param expired 杩囨湡鏃堕棿
*/
public List<String> getFileDownloadURLByStorageAttachmentIds(List<Long> storageAttachmentIds, BigDecimal expired) {
List<String> res = new ArrayList<>();
- List<StorageBlobVO> storageBlobVOS = getStorageBlobDTOsByStorageAttachmentIds(storageAttachmentIds);
+ List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(storageAttachmentIds);
for (StorageBlobVO storageBlobVO : storageBlobVOS) {
res.add(buildSignedUrl(storageBlobVO, "/download/", expired));
}
return res;
+ }
+
+ /**
+ * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢棰勮鍦板潃
+ *
+ * @param application 搴旂敤
+ * @param recordType 璁板綍绫诲瀷
+ * @param recordId 璁板綍id
+ */
+ public List<String> getFilePreviewURLByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId) {
+ List<StorageAttachment> storageAttachments = getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(application, recordType, recordId);
+ if (CollectionUtils.isEmpty(storageAttachments)) {
+ return new ArrayList<>();
+ }
+ return getFilePreviewURLByStorageAttachmentIds(storageAttachments.stream().map(StorageAttachment::getId).collect(Collectors.toList()));
+ }
+
+ /**
+ * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢棰勮鍦板潃瀛樺湪杩囨湡鏃堕棿
+ *
+ * @param application 搴旂敤
+ * @param recordType 璁板綍绫诲瀷
+ * @param recordId 璁板綍id
+ * @param expired 杩囨湡鏃堕棿锛堝垎閽燂級
+ */
+ public List<String> getFilePreviewURLByApplicationAndRecordTypeAndRecordIdAndExpired(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId, BigDecimal expired) {
+ List<StorageAttachment> storageAttachments = getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(application, recordType, recordId);
+ if (CollectionUtils.isEmpty(storageAttachments)) {
+ return new ArrayList<>();
+ }
+ return getFilePreviewURLByStorageAttachmentIds(storageAttachments.stream().map(StorageAttachment::getId).collect(Collectors.toList()), expired);
+ }
+
+ /**
+ * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢涓嬭浇鍦板潃
+ *
+ * @param application 搴旂敤
+ * @param recordType 璁板綍绫诲瀷
+ * @param recordId 璁板綍id
+ */
+ public List<String> getFileDownloadURLByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId) {
+ List<StorageAttachment> storageAttachments = getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(application, recordType, recordId);
+ if (CollectionUtils.isEmpty(storageAttachments)) {
+ return new ArrayList<>();
+ }
+ return getFileDownloadURLByStorageAttachmentIds(storageAttachments.stream().map(StorageAttachment::getId).collect(Collectors.toList()));
+ }
+
+ /**
+ * 閫氳繃鏂囦欢鍏宠仈id鑾峰彇鏂囦欢涓嬭浇鍦板潃瀛樺湪杩囨湡鏃堕棿
+ *
+ * @param application 搴旂敤
+ * @param recordType 璁板綍绫诲瀷
+ * @param recordId 璁板綍id
+ * @param expired 杩囨湡鏃堕棿锛堝垎閽燂級
+ */
+ public List<String> getFileDownloadURLByApplicationAndRecordTypeAndRecordIdAndExpired(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId, BigDecimal expired) {
+ List<StorageAttachment> storageAttachments = getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(application, recordType, recordId);
+ if (CollectionUtils.isEmpty(storageAttachments)) {
+ return new ArrayList<>();
+ }
+ return getFileDownloadURLByStorageAttachmentIds(storageAttachments.stream().map(StorageAttachment::getId).collect(Collectors.toList()), expired);
}
public String buildSignedPreviewUrl(StorageBlobVO storageBlob) {
@@ -496,7 +635,7 @@
}
/**
- * 鍘嬬缉鏂囦欢
+ * 鍘嬬缉鏂囦欢 鍥剧墖
*
* @param file 鏂囦欢
* @return 鍘嬬缉鍚庣殑鏂囦欢
--
Gitblit v1.9.3