功能:新增 OSS 备份和交接文档
新增阿里云 OSS 异步备份、重试调度和文件访问签名 URL 回退。 扩展文件存储元数据表结构,并更新作品、店铺、评论、消息和美甲师流程的图片 URL 解析。 新增面向后续 YumiNail 会话的低 token 交接文档。
This commit is contained in:
@@ -200,6 +200,13 @@
|
||||
<version>8.5.7</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Aliyun OSS backup storage -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.18.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
|
||||
@@ -9,61 +9,51 @@ import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* RabbitMQ配置类
|
||||
* 配置交换机、队列以及消息转换器
|
||||
*
|
||||
* @author xiaowang
|
||||
* @date 2026-02-12
|
||||
*/
|
||||
@Configuration
|
||||
public class RabbitMQConfig {
|
||||
|
||||
/**
|
||||
* 配置消息转换器为JSON格式
|
||||
*/
|
||||
public static final String EXAMPLE_QUEUE = "yuminail.example.queue";
|
||||
public static final String EXAMPLE_EXCHANGE = "yuminail.example.exchange";
|
||||
public static final String EXAMPLE_ROUTING_KEY = "yuminail.example.routing.key";
|
||||
|
||||
public static final String FILE_OSS_BACKUP_EXCHANGE = "yuminail.file.oss.backup.exchange";
|
||||
public static final String FILE_OSS_BACKUP_QUEUE = "yuminail.file.oss.backup.queue";
|
||||
public static final String FILE_OSS_BACKUP_ROUTING_KEY = "yuminail.file.oss.backup";
|
||||
|
||||
@Bean
|
||||
public MessageConverter jsonMessageConverter() {
|
||||
return new Jackson2JsonMessageConverter();
|
||||
}
|
||||
|
||||
// 示例队列和交换机配置,方便后续扩展
|
||||
public static final String EXAMPLE_QUEUE = "yuminail.example.queue";
|
||||
/**
|
||||
* Purpose: EXAMPLE_EXCHANGE supports RabbitMQConfig.java by holding or executing the example exchange business role.
|
||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
public static final String EXAMPLE_EXCHANGE = "yuminail.example.exchange";
|
||||
/**
|
||||
* Purpose: EXAMPLE_ROUTING_KEY supports RabbitMQConfig.java by holding or executing the example routing key business role.
|
||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
public static final String EXAMPLE_ROUTING_KEY = "yuminail.example.routing.key";
|
||||
|
||||
@Bean
|
||||
/**
|
||||
* Purpose: exampleQueue supports RabbitMQConfig.java by holding or executing the example queue business role.
|
||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
public Queue exampleQueue() {
|
||||
return new Queue(EXAMPLE_QUEUE, true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
/**
|
||||
* Purpose: exampleExchange supports RabbitMQConfig.java by holding or executing the example exchange business role.
|
||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
public DirectExchange exampleExchange() {
|
||||
return new DirectExchange(EXAMPLE_EXCHANGE);
|
||||
}
|
||||
|
||||
@Bean
|
||||
/**
|
||||
* Purpose: exampleBinding supports RabbitMQConfig.java by holding or executing the example binding business role.
|
||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
public Binding exampleBinding() {
|
||||
return BindingBuilder.bind(exampleQueue()).to(exampleExchange()).with(EXAMPLE_ROUTING_KEY);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue fileOssBackupQueue() {
|
||||
return new Queue(FILE_OSS_BACKUP_QUEUE, true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DirectExchange fileOssBackupExchange() {
|
||||
return new DirectExchange(FILE_OSS_BACKUP_EXCHANGE, true, false);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding fileOssBackupBinding() {
|
||||
return BindingBuilder.bind(fileOssBackupQueue())
|
||||
.to(fileOssBackupExchange())
|
||||
.with(FILE_OSS_BACKUP_ROUTING_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -22,6 +22,7 @@ import com.xiaowang.yuminailcore.modules.shop.mapper.ShopMapper;
|
||||
import com.xiaowang.yuminailcore.modules.user.mapper.UserMapper;
|
||||
import com.xiaowang.yuminailcore.modules.artist.service.NailArtistInfoService;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.ObjectStorageFileService;
|
||||
import com.xiaowang.yuminailcore.modules.file.support.ObjectStorageUrlSupport;
|
||||
import com.xiaowang.yuminailcore.modules.shop.support.UserShopBindingSupport;
|
||||
import com.xiaowang.yuminailcore.modules.artist.vo.NailArtistAvailabilityVO;
|
||||
import com.xiaowang.yuminailcore.modules.artist.vo.NailArtistProfileVO;
|
||||
@@ -102,6 +103,9 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
@Autowired
|
||||
private ObjectStorageFileService objectStorageFileService;
|
||||
|
||||
@Autowired
|
||||
private ObjectStorageUrlSupport objectStorageUrlSupport;
|
||||
|
||||
@Autowired(required = false)
|
||||
private ArtistScheduleMapper artistScheduleMapper;
|
||||
|
||||
@@ -696,7 +700,7 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
for (Long fileId : fileIds) {
|
||||
ObjectStorageFileVO file = fileMap.get(fileId);
|
||||
if (file != null && StringUtils.hasText(file.getFileUrl())) {
|
||||
urls.add(file.getFileUrl());
|
||||
urls.add(objectStorageUrlSupport.toAccessibleUrl(file));
|
||||
}
|
||||
}
|
||||
return urls;
|
||||
|
||||
+7
@@ -73,6 +73,13 @@ public class CommentController {
|
||||
ObjectStorageFileDTO dto = new ObjectStorageFileDTO();
|
||||
dto.setFileName(originalFilename);
|
||||
dto.setFileUrl(fileUrl);
|
||||
dto.setObjectName(objectName);
|
||||
dto.setMinioUrl(fileUrl);
|
||||
dto.setContentType(file.getContentType());
|
||||
dto.setFileSize(file.getSize());
|
||||
dto.setMinioUploadStatus(1);
|
||||
dto.setOssUploadStatus(0);
|
||||
dto.setOssRetryCount(0);
|
||||
dto.setStatus(1);
|
||||
|
||||
Long fileId = objectStorageFileService.createObjectStorageFile(dto);
|
||||
|
||||
+1
-12
@@ -12,7 +12,6 @@ import com.xiaowang.yuminailcore.modules.product.mapper.ProductMapper;
|
||||
import com.xiaowang.yuminailcore.modules.shop.mapper.ShopMapper;
|
||||
import com.xiaowang.yuminailcore.modules.user.mapper.UserMapper;
|
||||
import com.xiaowang.yuminailcore.modules.content.service.CommentService;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.MinioService;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.ObjectStorageFileService;
|
||||
import com.xiaowang.yuminailcore.modules.file.support.ObjectStorageUrlSupport;
|
||||
import com.xiaowang.yuminailcore.modules.content.vo.CommentVO;
|
||||
@@ -58,7 +57,6 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, CommentDO> im
|
||||
*/
|
||||
private final ProductMapper productMapper;
|
||||
private final ObjectStorageFileService objectStorageFileService;
|
||||
private final MinioService minioService;
|
||||
private final ObjectStorageUrlSupport objectStorageUrlSupport;
|
||||
|
||||
@Override
|
||||
@@ -561,16 +559,7 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, CommentDO> im
|
||||
if (fileVO == null || !StringUtils.hasText(fileVO.getFileUrl())) {
|
||||
continue;
|
||||
}
|
||||
String objectName = objectStorageUrlSupport.extractObjectName(fileVO.getFileUrl());
|
||||
if (!StringUtils.hasText(objectName)) {
|
||||
urls.add(fileVO.getFileUrl());
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
urls.add(minioService.getPresignedUrl(objectName, 60));
|
||||
} catch (Exception ignored) {
|
||||
urls.add(fileVO.getFileUrl());
|
||||
}
|
||||
urls.add(objectStorageUrlSupport.toAccessibleUrl(fileVO));
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.xiaowang.yuminailcore.modules.file.config;
|
||||
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "aliyun.oss")
|
||||
public class AliyunOssConfig {
|
||||
|
||||
private boolean enabled = false;
|
||||
private String endpoint;
|
||||
private String region;
|
||||
private String bucketName = "fingertipdesigner";
|
||||
private String accessKeyId;
|
||||
private String accessKeySecret;
|
||||
private int signedUrlExpireMinutes = 30;
|
||||
|
||||
@Bean(destroyMethod = "shutdown")
|
||||
@ConditionalOnProperty(prefix = "aliyun.oss", name = "enabled", havingValue = "true")
|
||||
public OSS aliyunOssClient() {
|
||||
if (!StringUtils.hasText(endpoint)
|
||||
|| !StringUtils.hasText(accessKeyId)
|
||||
|| !StringUtils.hasText(accessKeySecret)) {
|
||||
throw new IllegalStateException("Aliyun OSS is enabled but endpoint/accessKeyId/accessKeySecret is incomplete");
|
||||
}
|
||||
return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
}
|
||||
}
|
||||
+10
-8
@@ -4,11 +4,11 @@ import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.modules.product.mapper.EffectDiagramMapper;
|
||||
import com.xiaowang.yuminailcore.modules.product.mapper.ProductMapper;
|
||||
import com.xiaowang.yuminailcore.modules.shop.mapper.ShopMapper;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.MinioService;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.ObjectStorageFileService;
|
||||
import com.xiaowang.yuminailcore.modules.file.support.ObjectStorageUrlSupport;
|
||||
import com.xiaowang.yuminailcore.modules.file.vo.ObjectStorageFileVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -24,7 +24,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequiredArgsConstructor
|
||||
public class FrontendFileController {
|
||||
private final ObjectStorageFileService objectStorageFileService;
|
||||
private final MinioService minioService;
|
||||
private final ObjectStorageUrlSupport objectStorageUrlSupport;
|
||||
private final ProductMapper productMapper;
|
||||
private final ShopMapper shopMapper;
|
||||
@@ -46,12 +45,9 @@ public class FrontendFileController {
|
||||
return Result.error("文件不可公开访问");
|
||||
}
|
||||
|
||||
String objectName = objectStorageUrlSupport.extractObjectName(fileVO.getFileUrl());
|
||||
if (objectName == null || objectName.isEmpty()) {
|
||||
return Result.success(fileVO.getFileUrl());
|
||||
}
|
||||
|
||||
String signedUrl = minioService.getPresignedUrl(objectName, expiryTimeInMinutes);
|
||||
String signedUrl = hasObjectStorageReference(fileVO)
|
||||
? objectStorageUrlSupport.getSignedUrlOrThrow(fileVO, expiryTimeInMinutes)
|
||||
: fileVO.getFileUrl();
|
||||
return Result.success(signedUrl);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -59,6 +55,12 @@ public class FrontendFileController {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasObjectStorageReference(ObjectStorageFileVO fileVO) {
|
||||
return StringUtils.hasText(fileVO.getObjectName())
|
||||
|| StringUtils.hasText(objectStorageUrlSupport.extractObjectName(fileVO.getMinioUrl()))
|
||||
|| StringUtils.hasText(objectStorageUrlSupport.extractObjectName(fileVO.getFileUrl()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: isPublicFileReference prevents arbitrary uploaded files from being exposed through the public signing endpoint.
|
||||
* Usage: call with a file id and keep mapper checks in sync with public content tables.
|
||||
|
||||
+15
-6
@@ -110,6 +110,13 @@ public class ObjectStorageFileController {
|
||||
ObjectStorageFileDTO dto = new ObjectStorageFileDTO();
|
||||
dto.setFileName(originalFilename);
|
||||
dto.setFileUrl(fileUrl);
|
||||
dto.setObjectName(objectName);
|
||||
dto.setMinioUrl(fileUrl);
|
||||
dto.setContentType(preparedUploadFile.getContentType());
|
||||
dto.setFileSize(preparedUploadFile.getFileSize());
|
||||
dto.setMinioUploadStatus(1);
|
||||
dto.setOssUploadStatus(0);
|
||||
dto.setOssRetryCount(0);
|
||||
dto.setStatus(1);
|
||||
|
||||
Long fileId = objectStorageFileService.createObjectStorageFile(dto);
|
||||
@@ -153,6 +160,13 @@ public class ObjectStorageFileController {
|
||||
ObjectStorageFileDTO dto = new ObjectStorageFileDTO();
|
||||
dto.setFileName(originalFilename);
|
||||
dto.setFileUrl(fileUrl);
|
||||
dto.setObjectName(objectName);
|
||||
dto.setMinioUrl(fileUrl);
|
||||
dto.setContentType(file.getContentType());
|
||||
dto.setFileSize(file.getSize());
|
||||
dto.setMinioUploadStatus(1);
|
||||
dto.setOssUploadStatus(0);
|
||||
dto.setOssRetryCount(0);
|
||||
dto.setStatus(1);
|
||||
|
||||
Long fileId = objectStorageFileService.createObjectStorageFile(dto);
|
||||
@@ -175,12 +189,7 @@ public class ObjectStorageFileController {
|
||||
return Result.error("文件不存在");
|
||||
}
|
||||
|
||||
String objectName = objectStorageUrlSupport.extractObjectName(fileVO.getFileUrl());
|
||||
if (objectName == null || objectName.isEmpty()) {
|
||||
return Result.error("文件 URL 格式错误");
|
||||
}
|
||||
|
||||
String signedUrl = minioService.getPresignedUrl(objectName, expiryTimeInMinutes);
|
||||
String signedUrl = objectStorageUrlSupport.getSignedUrlOrThrow(fileVO, expiryTimeInMinutes);
|
||||
return Result.success(signedUrl);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
+22
@@ -24,6 +24,28 @@ public class ObjectStorageFileDTO {
|
||||
*/
|
||||
private String fileUrl;
|
||||
|
||||
private String objectName;
|
||||
|
||||
private String minioUrl;
|
||||
|
||||
private String ossUrl;
|
||||
|
||||
private String contentType;
|
||||
|
||||
private Long fileSize;
|
||||
|
||||
private Integer minioUploadStatus;
|
||||
|
||||
private Integer ossUploadStatus;
|
||||
|
||||
private Integer ossRetryCount;
|
||||
|
||||
private String ossLastError;
|
||||
|
||||
private LocalDateTime ossUploadedAt;
|
||||
|
||||
private LocalDateTime ossLastRetryTime;
|
||||
|
||||
/**
|
||||
* 文件状态:1-可用,0-不可用,2-回收站
|
||||
*/
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.xiaowang.yuminailcore.modules.file.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OssBackupUploadMessage {
|
||||
|
||||
private Long fileId;
|
||||
}
|
||||
+33
@@ -32,6 +32,39 @@ public class ObjectStorageFileDO extends BaseEntity {
|
||||
@TableField("file_url")
|
||||
private String fileUrl;
|
||||
|
||||
@TableField("object_name")
|
||||
private String objectName;
|
||||
|
||||
@TableField("minio_url")
|
||||
private String minioUrl;
|
||||
|
||||
@TableField("oss_url")
|
||||
private String ossUrl;
|
||||
|
||||
@TableField("content_type")
|
||||
private String contentType;
|
||||
|
||||
@TableField("file_size")
|
||||
private Long fileSize;
|
||||
|
||||
@TableField("minio_upload_status")
|
||||
private Integer minioUploadStatus;
|
||||
|
||||
@TableField("oss_upload_status")
|
||||
private Integer ossUploadStatus;
|
||||
|
||||
@TableField("oss_retry_count")
|
||||
private Integer ossRetryCount;
|
||||
|
||||
@TableField("oss_last_error")
|
||||
private String ossLastError;
|
||||
|
||||
@TableField("oss_uploaded_at")
|
||||
private LocalDateTime ossUploadedAt;
|
||||
|
||||
@TableField("oss_last_retry_time")
|
||||
private LocalDateTime ossLastRetryTime;
|
||||
|
||||
/**
|
||||
* 文件状态:1-可用,0-不可用,2-回收站
|
||||
*/
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.xiaowang.yuminailcore.modules.file.mq;
|
||||
|
||||
import com.xiaowang.yuminailcore.config.RabbitMQConfig;
|
||||
import com.xiaowang.yuminailcore.modules.file.dto.OssBackupUploadMessage;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.OssBackupService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class OssBackupMessageListener {
|
||||
|
||||
private final OssBackupService ossBackupService;
|
||||
|
||||
@RabbitListener(queues = RabbitMQConfig.FILE_OSS_BACKUP_QUEUE)
|
||||
public void handle(OssBackupUploadMessage message) {
|
||||
if (message == null || message.getFileId() == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
ossBackupService.backupFileToOss(message.getFileId());
|
||||
} catch (Exception e) {
|
||||
log.warn("Handle OSS backup message failed, fileId={}", message.getFileId(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.xiaowang.yuminailcore.modules.file.mq;
|
||||
|
||||
import com.xiaowang.yuminailcore.config.RabbitMQConfig;
|
||||
import com.xiaowang.yuminailcore.modules.file.dto.OssBackupUploadMessage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class OssBackupMessagePublisher {
|
||||
|
||||
private final RabbitTemplate rabbitTemplate;
|
||||
|
||||
public void publish(Long fileId) {
|
||||
if (fileId == null || fileId <= 0) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
rabbitTemplate.convertAndSend(
|
||||
RabbitMQConfig.FILE_OSS_BACKUP_EXCHANGE,
|
||||
RabbitMQConfig.FILE_OSS_BACKUP_ROUTING_KEY,
|
||||
new OssBackupUploadMessage(fileId)
|
||||
);
|
||||
} catch (Exception e) {
|
||||
log.warn("Publish OSS backup message failed, fileId={}", fileId, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.xiaowang.yuminailcore.modules.file.scheduler;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.xiaowang.yuminailcore.modules.file.entity.ObjectStorageFileDO;
|
||||
import com.xiaowang.yuminailcore.modules.file.mapper.ObjectStorageFileMapper;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.OssBackupService;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.impl.OssBackupServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class OssBackupRetryScheduler {
|
||||
|
||||
private static final int BATCH_LIMIT = 500;
|
||||
|
||||
private final ObjectStorageFileMapper objectStorageFileMapper;
|
||||
private final OssBackupService ossBackupService;
|
||||
|
||||
@Scheduled(cron = "0 0 2 * * ?", zone = "Asia/Shanghai")
|
||||
public void retryPendingOrFailedBackups() {
|
||||
List<ObjectStorageFileDO> files = objectStorageFileMapper.selectList(
|
||||
Wrappers.lambdaQuery(ObjectStorageFileDO.class)
|
||||
.eq(ObjectStorageFileDO::getStatus, 1)
|
||||
.eq(ObjectStorageFileDO::getMinioUploadStatus, OssBackupServiceImpl.UPLOAD_STATUS_SUCCEEDED)
|
||||
.in(ObjectStorageFileDO::getOssUploadStatus,
|
||||
OssBackupServiceImpl.UPLOAD_STATUS_PENDING,
|
||||
OssBackupServiceImpl.UPLOAD_STATUS_FAILED)
|
||||
.last("LIMIT " + BATCH_LIMIT)
|
||||
);
|
||||
for (ObjectStorageFileDO file : files) {
|
||||
try {
|
||||
ossBackupService.backupFileToOss(file.getId());
|
||||
} catch (Exception e) {
|
||||
log.warn("Retry OSS backup failed, fileId={}", file.getId(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.xiaowang.yuminailcore.modules.file.service;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public interface AliyunOssService {
|
||||
|
||||
String uploadStream(String objectName, InputStream inputStream, long fileSize, String contentType);
|
||||
|
||||
String getPresignedUrl(String objectName);
|
||||
}
|
||||
+2
@@ -73,4 +73,6 @@ public interface ObjectStorageFileService extends IService<ObjectStorageFileDO>
|
||||
* @return 文件VO列表
|
||||
*/
|
||||
List<ObjectStorageFileVO> listObjectStorageFilesByStatus(Integer status);
|
||||
|
||||
void evictObjectStorageFileCache(Long id);
|
||||
}
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package com.xiaowang.yuminailcore.modules.file.service;
|
||||
|
||||
public interface OssBackupService {
|
||||
|
||||
void backupFileToOss(Long fileId);
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.xiaowang.yuminailcore.modules.file.service.impl;
|
||||
|
||||
import com.aliyun.oss.HttpMethod;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.model.GeneratePresignedUrlRequest;
|
||||
import com.aliyun.oss.model.ObjectMetadata;
|
||||
import com.aliyun.oss.model.PutObjectRequest;
|
||||
import com.xiaowang.yuminailcore.modules.file.config.AliyunOssConfig;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.AliyunOssService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AliyunOssServiceImpl implements AliyunOssService {
|
||||
|
||||
private final ObjectProvider<OSS> ossClientProvider;
|
||||
private final AliyunOssConfig aliyunOssConfig;
|
||||
|
||||
@Override
|
||||
public String uploadStream(String objectName, InputStream inputStream, long fileSize, String contentType) {
|
||||
OSS ossClient = requireClient();
|
||||
ObjectMetadata metadata = new ObjectMetadata();
|
||||
if (fileSize >= 0) {
|
||||
metadata.setContentLength(fileSize);
|
||||
}
|
||||
if (StringUtils.hasText(contentType)) {
|
||||
metadata.setContentType(contentType);
|
||||
}
|
||||
ossClient.putObject(new PutObjectRequest(aliyunOssConfig.getBucketName(), objectName, inputStream, metadata));
|
||||
log.info("Aliyun OSS backup uploaded: {}", objectName);
|
||||
return "oss://" + aliyunOssConfig.getBucketName() + "/" + objectName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPresignedUrl(String objectName) {
|
||||
OSS ossClient = requireClient();
|
||||
Date expiration = new Date(System.currentTimeMillis()
|
||||
+ aliyunOssConfig.getSignedUrlExpireMinutes() * 60L * 1000L);
|
||||
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(
|
||||
aliyunOssConfig.getBucketName(),
|
||||
objectName,
|
||||
HttpMethod.GET
|
||||
);
|
||||
request.setExpiration(expiration);
|
||||
URL url = ossClient.generatePresignedUrl(request);
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
private OSS requireClient() {
|
||||
OSS ossClient = ossClientProvider.getIfAvailable();
|
||||
if (ossClient == null) {
|
||||
throw new IllegalStateException("Aliyun OSS is not enabled or not configured");
|
||||
}
|
||||
return ossClient;
|
||||
}
|
||||
}
|
||||
+49
-10
@@ -7,12 +7,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiaowang.yuminailcore.modules.file.dto.ObjectStorageFileDTO;
|
||||
import com.xiaowang.yuminailcore.modules.file.entity.ObjectStorageFileDO;
|
||||
import com.xiaowang.yuminailcore.modules.file.mapper.ObjectStorageFileMapper;
|
||||
import com.xiaowang.yuminailcore.modules.file.mq.OssBackupMessagePublisher;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.ObjectStorageFileService;
|
||||
import com.xiaowang.yuminailcore.support.cache.MultiLevelCacheService;
|
||||
import com.xiaowang.yuminailcore.modules.file.vo.ObjectStorageFileVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Collection;
|
||||
@@ -53,6 +55,7 @@ public class ObjectStorageFileServiceImpl extends ServiceImpl<ObjectStorageFileM
|
||||
* Variable `appCacheProperties`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AppCacheProperties appCacheProperties;
|
||||
private final OssBackupMessagePublisher ossBackupMessagePublisher;
|
||||
|
||||
@Override
|
||||
/**
|
||||
@@ -63,13 +66,10 @@ public class ObjectStorageFileServiceImpl extends ServiceImpl<ObjectStorageFileM
|
||||
*/
|
||||
public Long createObjectStorageFile(ObjectStorageFileDTO objectStorageFileDTO) {
|
||||
ObjectStorageFileDO objectStorageFileDO = new ObjectStorageFileDO();
|
||||
objectStorageFileDO.setFileName(objectStorageFileDTO.getFileName());
|
||||
objectStorageFileDO.setFileUrl(objectStorageFileDTO.getFileUrl());
|
||||
objectStorageFileDO.setStatus(objectStorageFileDTO.getStatus());
|
||||
objectStorageFileDO.setDeleteTime(objectStorageFileDTO.getDeleteTime());
|
||||
objectStorageFileDO.setRecycleTime(objectStorageFileDTO.getRecycleTime());
|
||||
applyDTO(objectStorageFileDO, objectStorageFileDTO);
|
||||
objectStorageFileMapper.insert(objectStorageFileDO);
|
||||
evictFileCache(objectStorageFileDO.getId());
|
||||
publishOssBackupIfNeeded(objectStorageFileDO);
|
||||
return objectStorageFileDO.getId();
|
||||
}
|
||||
|
||||
@@ -86,11 +86,7 @@ public class ObjectStorageFileServiceImpl extends ServiceImpl<ObjectStorageFileM
|
||||
if (objectStorageFileDO == null) {
|
||||
return false;
|
||||
}
|
||||
objectStorageFileDO.setFileName(objectStorageFileDTO.getFileName());
|
||||
objectStorageFileDO.setFileUrl(objectStorageFileDTO.getFileUrl());
|
||||
objectStorageFileDO.setStatus(objectStorageFileDTO.getStatus());
|
||||
objectStorageFileDO.setDeleteTime(objectStorageFileDTO.getDeleteTime());
|
||||
objectStorageFileDO.setRecycleTime(objectStorageFileDTO.getRecycleTime());
|
||||
applyDTO(objectStorageFileDO, objectStorageFileDTO);
|
||||
boolean updated = objectStorageFileMapper.updateById(objectStorageFileDO) > 0;
|
||||
if (updated) {
|
||||
/**
|
||||
@@ -229,6 +225,17 @@ public class ObjectStorageFileServiceImpl extends ServiceImpl<ObjectStorageFileM
|
||||
objectStorageFileVO.setId(objectStorageFileDO.getId());
|
||||
objectStorageFileVO.setFileName(objectStorageFileDO.getFileName());
|
||||
objectStorageFileVO.setFileUrl(objectStorageFileDO.getFileUrl());
|
||||
objectStorageFileVO.setObjectName(objectStorageFileDO.getObjectName());
|
||||
objectStorageFileVO.setMinioUrl(objectStorageFileDO.getMinioUrl());
|
||||
objectStorageFileVO.setOssUrl(objectStorageFileDO.getOssUrl());
|
||||
objectStorageFileVO.setContentType(objectStorageFileDO.getContentType());
|
||||
objectStorageFileVO.setFileSize(objectStorageFileDO.getFileSize());
|
||||
objectStorageFileVO.setMinioUploadStatus(objectStorageFileDO.getMinioUploadStatus());
|
||||
objectStorageFileVO.setOssUploadStatus(objectStorageFileDO.getOssUploadStatus());
|
||||
objectStorageFileVO.setOssRetryCount(objectStorageFileDO.getOssRetryCount());
|
||||
objectStorageFileVO.setOssLastError(objectStorageFileDO.getOssLastError());
|
||||
objectStorageFileVO.setOssUploadedAt(objectStorageFileDO.getOssUploadedAt());
|
||||
objectStorageFileVO.setOssLastRetryTime(objectStorageFileDO.getOssLastRetryTime());
|
||||
objectStorageFileVO.setCreateTime(objectStorageFileDO.getCreateTime());
|
||||
objectStorageFileVO.setStatus(objectStorageFileDO.getStatus());
|
||||
objectStorageFileVO.setDeleteTime(objectStorageFileDO.getDeleteTime());
|
||||
@@ -236,6 +243,38 @@ public class ObjectStorageFileServiceImpl extends ServiceImpl<ObjectStorageFileM
|
||||
return objectStorageFileVO;
|
||||
}
|
||||
|
||||
private void applyDTO(ObjectStorageFileDO objectStorageFileDO, ObjectStorageFileDTO objectStorageFileDTO) {
|
||||
objectStorageFileDO.setFileName(objectStorageFileDTO.getFileName());
|
||||
objectStorageFileDO.setFileUrl(objectStorageFileDTO.getFileUrl());
|
||||
objectStorageFileDO.setObjectName(objectStorageFileDTO.getObjectName());
|
||||
objectStorageFileDO.setMinioUrl(objectStorageFileDTO.getMinioUrl());
|
||||
objectStorageFileDO.setOssUrl(objectStorageFileDTO.getOssUrl());
|
||||
objectStorageFileDO.setContentType(objectStorageFileDTO.getContentType());
|
||||
objectStorageFileDO.setFileSize(objectStorageFileDTO.getFileSize());
|
||||
objectStorageFileDO.setMinioUploadStatus(objectStorageFileDTO.getMinioUploadStatus());
|
||||
objectStorageFileDO.setOssUploadStatus(objectStorageFileDTO.getOssUploadStatus());
|
||||
objectStorageFileDO.setOssRetryCount(objectStorageFileDTO.getOssRetryCount());
|
||||
objectStorageFileDO.setOssLastError(objectStorageFileDTO.getOssLastError());
|
||||
objectStorageFileDO.setOssUploadedAt(objectStorageFileDTO.getOssUploadedAt());
|
||||
objectStorageFileDO.setOssLastRetryTime(objectStorageFileDTO.getOssLastRetryTime());
|
||||
objectStorageFileDO.setStatus(objectStorageFileDTO.getStatus());
|
||||
objectStorageFileDO.setDeleteTime(objectStorageFileDTO.getDeleteTime());
|
||||
objectStorageFileDO.setRecycleTime(objectStorageFileDTO.getRecycleTime());
|
||||
}
|
||||
|
||||
private void publishOssBackupIfNeeded(ObjectStorageFileDO objectStorageFileDO) {
|
||||
if (StringUtils.hasText(objectStorageFileDO.getObjectName())
|
||||
&& Integer.valueOf(1).equals(objectStorageFileDO.getMinioUploadStatus())
|
||||
&& Integer.valueOf(0).equals(objectStorageFileDO.getOssUploadStatus())) {
|
||||
ossBackupMessagePublisher.publish(objectStorageFileDO.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evictObjectStorageFileCache(Long id) {
|
||||
evictFileCache(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run business method `evictFileCache`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
package com.xiaowang.yuminailcore.modules.file.service.impl;
|
||||
|
||||
import com.xiaowang.yuminailcore.modules.file.entity.ObjectStorageFileDO;
|
||||
import com.xiaowang.yuminailcore.modules.file.mapper.ObjectStorageFileMapper;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.AliyunOssService;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.MinioService;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.ObjectStorageFileService;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.OssBackupService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class OssBackupServiceImpl implements OssBackupService {
|
||||
|
||||
public static final int UPLOAD_STATUS_PENDING = 0;
|
||||
public static final int UPLOAD_STATUS_SUCCEEDED = 1;
|
||||
public static final int UPLOAD_STATUS_FAILED = 2;
|
||||
|
||||
private static final int ACTIVE_STATUS = 1;
|
||||
private static final int MAX_ERROR_LENGTH = 500;
|
||||
|
||||
private final ObjectStorageFileMapper objectStorageFileMapper;
|
||||
private final MinioService minioService;
|
||||
private final AliyunOssService aliyunOssService;
|
||||
private final ObjectStorageFileService objectStorageFileService;
|
||||
|
||||
@Override
|
||||
public void backupFileToOss(Long fileId) {
|
||||
if (fileId == null || fileId <= 0) {
|
||||
return;
|
||||
}
|
||||
ObjectStorageFileDO file = objectStorageFileMapper.selectById(fileId);
|
||||
if (!shouldBackup(file)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try (InputStream inputStream = minioService.downloadFile(file.getObjectName())) {
|
||||
String ossUrl = aliyunOssService.uploadStream(
|
||||
file.getObjectName(),
|
||||
inputStream,
|
||||
file.getFileSize() == null ? -1L : file.getFileSize(),
|
||||
file.getContentType()
|
||||
);
|
||||
markSucceeded(file, ossUrl);
|
||||
} catch (Exception e) {
|
||||
log.warn("Backup file to Aliyun OSS failed, fileId={}", fileId, e);
|
||||
markFailed(file, e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldBackup(ObjectStorageFileDO file) {
|
||||
return file != null
|
||||
&& Integer.valueOf(ACTIVE_STATUS).equals(file.getStatus())
|
||||
&& Integer.valueOf(UPLOAD_STATUS_SUCCEEDED).equals(file.getMinioUploadStatus())
|
||||
&& !Integer.valueOf(UPLOAD_STATUS_SUCCEEDED).equals(file.getOssUploadStatus())
|
||||
&& StringUtils.hasText(file.getObjectName());
|
||||
}
|
||||
|
||||
private void markSucceeded(ObjectStorageFileDO file, String ossUrl) {
|
||||
file.setOssUrl(ossUrl);
|
||||
file.setOssUploadStatus(UPLOAD_STATUS_SUCCEEDED);
|
||||
file.setOssUploadedAt(LocalDateTime.now());
|
||||
file.setOssLastError(null);
|
||||
objectStorageFileMapper.updateById(file);
|
||||
objectStorageFileService.evictObjectStorageFileCache(file.getId());
|
||||
}
|
||||
|
||||
private void markFailed(ObjectStorageFileDO file, Exception e) {
|
||||
file.setOssUploadStatus(UPLOAD_STATUS_FAILED);
|
||||
file.setOssRetryCount((file.getOssRetryCount() == null ? 0 : file.getOssRetryCount()) + 1);
|
||||
file.setOssLastError(truncateError(e));
|
||||
file.setOssLastRetryTime(LocalDateTime.now());
|
||||
objectStorageFileMapper.updateById(file);
|
||||
objectStorageFileService.evictObjectStorageFileCache(file.getId());
|
||||
}
|
||||
|
||||
private String truncateError(Exception e) {
|
||||
String message = e.getClass().getSimpleName() + ": " + (e.getMessage() == null ? "" : e.getMessage());
|
||||
return message.length() <= MAX_ERROR_LENGTH ? message : message.substring(0, MAX_ERROR_LENGTH);
|
||||
}
|
||||
}
|
||||
+167
-49
@@ -1,7 +1,9 @@
|
||||
package com.xiaowang.yuminailcore.modules.file.support;
|
||||
|
||||
import com.xiaowang.yuminailcore.config.MinioConfig;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.AliyunOssService;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.MinioService;
|
||||
import com.xiaowang.yuminailcore.modules.file.vo.ObjectStorageFileVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -9,35 +11,22 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* 统一处理对象存储文件地址的提取、签名与归一化,避免把私有桶原始地址直接暴露给前端。
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class ObjectStorageUrlSupport {
|
||||
|
||||
/**
|
||||
* Purpose: DEFAULT_SIGNED_URL_EXPIRE_MINUTES supports ObjectStorageUrlSupport.java by holding or executing the default signed url expire minutes business role.
|
||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
private static final int DEFAULT_SIGNED_URL_EXPIRE_MINUTES = 60;
|
||||
private static final long MINIO_HEALTH_CACHE_MILLIS = 60_000L;
|
||||
private static final int UPLOAD_STATUS_SUCCEEDED = 1;
|
||||
|
||||
/**
|
||||
* Purpose: minioService supports ObjectStorageUrlSupport.java by holding or executing the minio service business role.
|
||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
private final MinioService minioService;
|
||||
/**
|
||||
* Purpose: minioConfig supports ObjectStorageUrlSupport.java by holding or executing the minio config business role.
|
||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
private final MinioConfig minioConfig;
|
||||
private final AliyunOssService aliyunOssService;
|
||||
|
||||
private volatile boolean minioHealthy = true;
|
||||
private volatile long minioHealthCheckedAt = 0L;
|
||||
|
||||
/**
|
||||
* Purpose: toAccessibleUrl supports ObjectStorageUrlSupport.java by holding or executing the to accessible url business role.
|
||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
public String toAccessibleUrl(String fileUrl) {
|
||||
if (!StringUtils.hasText(fileUrl)) {
|
||||
return fileUrl;
|
||||
@@ -47,17 +36,77 @@ public class ObjectStorageUrlSupport {
|
||||
return fileUrl;
|
||||
}
|
||||
try {
|
||||
return minioService.getPresignedUrl(objectName, DEFAULT_SIGNED_URL_EXPIRE_MINUTES);
|
||||
return signWithMinio(objectName, DEFAULT_SIGNED_URL_EXPIRE_MINUTES);
|
||||
} catch (Exception e) {
|
||||
log.warn("生成对象存储签名地址失败,回退原地址: {}", fileUrl, e);
|
||||
return fileUrl;
|
||||
log.warn("Generate MinIO signed URL failed, fallback to safe display URL: {}", fileUrl, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: toStoredUrl supports ObjectStorageUrlSupport.java by holding or executing the to stored url business role.
|
||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
public String toAccessibleUrl(ObjectStorageFileVO file) {
|
||||
return toAccessibleUrl(file, DEFAULT_SIGNED_URL_EXPIRE_MINUTES);
|
||||
}
|
||||
|
||||
public String toAccessibleUrl(ObjectStorageFileVO file, Integer expiryTimeInMinutes) {
|
||||
if (file == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return getSignedUrlOrThrow(file, expiryTimeInMinutes);
|
||||
} catch (Exception e) {
|
||||
String fallback = hasObjectStorageReference(file) ? null : firstText(file.getFileUrl(), file.getMinioUrl());
|
||||
log.warn("Generate object storage signed URL failed, fallback to safe display URL, fileId={}", file.getId(), e);
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
public String getSignedUrlOrThrow(ObjectStorageFileVO file, Integer expiryTimeInMinutes) {
|
||||
if (file == null) {
|
||||
throw new IllegalStateException("No available object storage signed URL: file is null");
|
||||
}
|
||||
String objectName = resolveObjectName(file);
|
||||
if (!StringUtils.hasText(objectName)) {
|
||||
throw new IllegalStateException("No available object storage signed URL: objectName is empty");
|
||||
}
|
||||
|
||||
Exception minioFailure = null;
|
||||
int minioExpiry = expiryTimeInMinutes == null || expiryTimeInMinutes <= 0
|
||||
? DEFAULT_SIGNED_URL_EXPIRE_MINUTES
|
||||
: expiryTimeInMinutes;
|
||||
if (shouldTryMinio()) {
|
||||
try {
|
||||
return signWithMinio(objectName, minioExpiry);
|
||||
} catch (Exception e) {
|
||||
minioFailure = e;
|
||||
markMinioHealth(false);
|
||||
log.warn("Generate MinIO signed URL failed, fileId={}, objectName={}", file.getId(), objectName, e);
|
||||
}
|
||||
}
|
||||
|
||||
if (Integer.valueOf(UPLOAD_STATUS_SUCCEEDED).equals(file.getOssUploadStatus())) {
|
||||
try {
|
||||
return aliyunOssService.getPresignedUrl(objectName);
|
||||
} catch (Exception e) {
|
||||
IllegalStateException failure = new IllegalStateException(
|
||||
"No available object storage signed URL for fileId=" + file.getId(),
|
||||
e
|
||||
);
|
||||
if (minioFailure != null) {
|
||||
failure.addSuppressed(minioFailure);
|
||||
}
|
||||
throw failure;
|
||||
}
|
||||
}
|
||||
|
||||
IllegalStateException failure = new IllegalStateException(
|
||||
"No available object storage signed URL for fileId=" + file.getId()
|
||||
);
|
||||
if (minioFailure != null) {
|
||||
failure.addSuppressed(minioFailure);
|
||||
}
|
||||
throw failure;
|
||||
}
|
||||
|
||||
public String toStoredUrl(String fileUrl) {
|
||||
if (!StringUtils.hasText(fileUrl)) {
|
||||
return fileUrl;
|
||||
@@ -69,10 +118,6 @@ public class ObjectStorageUrlSupport {
|
||||
return minioService.getFileUrl(objectName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: extractObjectName supports ObjectStorageUrlSupport.java by holding or executing the extract object name business role.
|
||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
public String extractObjectName(String fileUrl) {
|
||||
if (!StringUtils.hasText(fileUrl)) {
|
||||
return "";
|
||||
@@ -89,17 +134,60 @@ public class ObjectStorageUrlSupport {
|
||||
if (!StringUtils.hasText(path)) {
|
||||
return "";
|
||||
}
|
||||
return extractObjectNameFromPath(path);
|
||||
return extractObjectNameFromUri(fileUri);
|
||||
} catch (Exception e) {
|
||||
log.warn("解析对象存储文件地址失败: {}", fileUrl, e);
|
||||
log.warn("Parse object storage URL failed: {}", fileUrl, e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: extractObjectNameFromPath supports ObjectStorageUrlSupport.java by holding or executing the extract object name from path business role.
|
||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
private String resolveObjectName(ObjectStorageFileVO file) {
|
||||
if (StringUtils.hasText(file.getObjectName())) {
|
||||
return file.getObjectName();
|
||||
}
|
||||
String objectName = extractObjectName(file.getMinioUrl());
|
||||
if (StringUtils.hasText(objectName)) {
|
||||
return objectName;
|
||||
}
|
||||
return extractObjectName(file.getFileUrl());
|
||||
}
|
||||
|
||||
private boolean hasObjectStorageReference(ObjectStorageFileVO file) {
|
||||
return StringUtils.hasText(file.getObjectName())
|
||||
|| StringUtils.hasText(extractObjectName(file.getMinioUrl()))
|
||||
|| StringUtils.hasText(extractObjectName(file.getFileUrl()));
|
||||
}
|
||||
|
||||
private String signWithMinio(String objectName, int expiryTimeInMinutes) throws Exception {
|
||||
String signedUrl = minioService.getPresignedUrl(objectName, expiryTimeInMinutes);
|
||||
markMinioHealth(true);
|
||||
return signedUrl;
|
||||
}
|
||||
|
||||
private boolean shouldTryMinio() {
|
||||
if (minioHealthy) {
|
||||
return true;
|
||||
}
|
||||
return System.currentTimeMillis() - minioHealthCheckedAt >= MINIO_HEALTH_CACHE_MILLIS;
|
||||
}
|
||||
|
||||
private void markMinioHealth(boolean healthy) {
|
||||
minioHealthy = healthy;
|
||||
minioHealthCheckedAt = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private String firstText(String... values) {
|
||||
if (values == null) {
|
||||
return null;
|
||||
}
|
||||
for (String value : values) {
|
||||
if (StringUtils.hasText(value)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String extractObjectNameFromPath(String path) {
|
||||
String bucketPrefix = "/" + minioConfig.getBucketName() + "/";
|
||||
if (path.startsWith(bucketPrefix)) {
|
||||
@@ -110,7 +198,7 @@ public class ObjectStorageUrlSupport {
|
||||
try {
|
||||
endpointPath = URI.create(minioConfig.getEndpoint()).getPath();
|
||||
} catch (Exception e) {
|
||||
log.warn("解析 MinIO endpoint 失败: {}", minioConfig.getEndpoint(), e);
|
||||
log.warn("Parse MinIO endpoint failed: {}", minioConfig.getEndpoint(), e);
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(endpointPath) && !"/".equals(endpointPath)) {
|
||||
@@ -131,10 +219,48 @@ public class ObjectStorageUrlSupport {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: trimBucketPrefix supports ObjectStorageUrlSupport.java by holding or executing the trim bucket prefix business role.
|
||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
private String extractObjectNameFromUri(URI fileUri) {
|
||||
String objectName = extractObjectNameFromPath(fileUri.getPath());
|
||||
if (StringUtils.hasText(objectName)) {
|
||||
return objectName;
|
||||
}
|
||||
|
||||
try {
|
||||
URI endpointUri = URI.create(minioConfig.getEndpoint());
|
||||
if (!sameAuthority(fileUri, endpointUri)) {
|
||||
return "";
|
||||
}
|
||||
return stripFirstPathSegment(fileUri.getPath());
|
||||
} catch (Exception e) {
|
||||
log.warn("Parse MinIO endpoint failed: {}", minioConfig.getEndpoint(), e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private boolean sameAuthority(URI left, URI right) {
|
||||
return left.getScheme() != null
|
||||
&& left.getScheme().equalsIgnoreCase(right.getScheme())
|
||||
&& left.getHost() != null
|
||||
&& left.getHost().equalsIgnoreCase(right.getHost())
|
||||
&& normalizedPort(left) == normalizedPort(right);
|
||||
}
|
||||
|
||||
private int normalizedPort(URI uri) {
|
||||
if (uri.getPort() >= 0) {
|
||||
return uri.getPort();
|
||||
}
|
||||
return "https".equalsIgnoreCase(uri.getScheme()) ? 443 : 80;
|
||||
}
|
||||
|
||||
private String stripFirstPathSegment(String path) {
|
||||
String normalizedPath = stripLeadingSlash(path);
|
||||
int slashIndex = normalizedPath.indexOf('/');
|
||||
if (slashIndex < 0 || slashIndex == normalizedPath.length() - 1) {
|
||||
return "";
|
||||
}
|
||||
return normalizedPath.substring(slashIndex + 1);
|
||||
}
|
||||
|
||||
private String trimBucketPrefix(String rawValue) {
|
||||
String normalized = stripLeadingSlash(rawValue);
|
||||
String bucketPrefix = minioConfig.getBucketName() + "/";
|
||||
@@ -144,10 +270,6 @@ public class ObjectStorageUrlSupport {
|
||||
return normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: stripLeadingSlash supports ObjectStorageUrlSupport.java by holding or executing the strip leading slash business role.
|
||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
private String stripLeadingSlash(String rawValue) {
|
||||
String normalized = rawValue;
|
||||
while (normalized.startsWith("/")) {
|
||||
@@ -156,10 +278,6 @@ public class ObjectStorageUrlSupport {
|
||||
return normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: stripQuery supports ObjectStorageUrlSupport.java by holding or executing the strip query business role.
|
||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
private String stripQuery(String rawValue) {
|
||||
int queryIndex = rawValue.indexOf('?');
|
||||
return queryIndex >= 0 ? rawValue.substring(0, queryIndex) : rawValue;
|
||||
|
||||
+22
@@ -29,6 +29,28 @@ public class ObjectStorageFileVO {
|
||||
*/
|
||||
private String fileUrl;
|
||||
|
||||
private String objectName;
|
||||
|
||||
private String minioUrl;
|
||||
|
||||
private String ossUrl;
|
||||
|
||||
private String contentType;
|
||||
|
||||
private Long fileSize;
|
||||
|
||||
private Integer minioUploadStatus;
|
||||
|
||||
private Integer ossUploadStatus;
|
||||
|
||||
private Integer ossRetryCount;
|
||||
|
||||
private String ossLastError;
|
||||
|
||||
private LocalDateTime ossUploadedAt;
|
||||
|
||||
private LocalDateTime ossLastRetryTime;
|
||||
|
||||
/**
|
||||
* 文件上传时间
|
||||
*/
|
||||
|
||||
+1
-1
@@ -692,7 +692,7 @@ public class SystemMessageServiceImpl extends ServiceImpl<SystemMessageMapper, S
|
||||
if (imageFile == null || !StringUtils.hasText(imageFile.getFileUrl())) {
|
||||
return null;
|
||||
}
|
||||
return objectStorageUrlSupport.toAccessibleUrl(imageFile.getFileUrl());
|
||||
return objectStorageUrlSupport.toAccessibleUrl(imageFile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-1
@@ -16,6 +16,7 @@ import com.xiaowang.yuminailcore.modules.product.mapper.ProductMapper;
|
||||
import com.xiaowang.yuminailcore.modules.shop.mapper.ShopMapper;
|
||||
import com.xiaowang.yuminailcore.modules.product.mapper.TagMapper;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.ObjectStorageFileService;
|
||||
import com.xiaowang.yuminailcore.modules.file.support.ObjectStorageUrlSupport;
|
||||
import com.xiaowang.yuminailcore.modules.product.service.ProductService;
|
||||
import com.xiaowang.yuminailcore.modules.artist.support.BookableArtistSupport;
|
||||
import com.xiaowang.yuminailcore.support.cache.MultiLevelCacheService;
|
||||
@@ -86,6 +87,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im
|
||||
* Variable `objectStorageFileService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ObjectStorageFileService objectStorageFileService;
|
||||
private final ObjectStorageUrlSupport objectStorageUrlSupport;
|
||||
/**
|
||||
* Variable `couponMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
@@ -488,7 +490,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im
|
||||
for (Long fileId : parseDelimitedLongIds(productDO.getImageFileIds(), ",")) {
|
||||
ObjectStorageFileVO fileVO = context.files().get(fileId);
|
||||
if (fileVO != null && StringUtils.hasText(fileVO.getFileUrl())) {
|
||||
imageUrls.add(fileVO.getFileUrl());
|
||||
imageUrls.add(objectStorageUrlSupport.toAccessibleUrl(fileVO));
|
||||
}
|
||||
}
|
||||
productVO.setImageUrls(imageUrls);
|
||||
|
||||
+1
-1
@@ -694,7 +694,7 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
|
||||
for (Long fileId : fileIds) {
|
||||
ObjectStorageFileVO file = fileMap.get(fileId);
|
||||
if (file != null && StringUtils.hasText(file.getFileUrl())) {
|
||||
urls.add(objectStorageUrlSupport.toAccessibleUrl(file.getFileUrl()));
|
||||
urls.add(objectStorageUrlSupport.toAccessibleUrl(file));
|
||||
}
|
||||
}
|
||||
return urls;
|
||||
|
||||
@@ -276,6 +276,17 @@ create table t_object_storage_file
|
||||
primary key comment '对象存储文件主键索引',
|
||||
file_name varchar(100) not null comment '文件名称',
|
||||
file_url text not null comment '文件访问链接',
|
||||
object_name varchar(512) null comment '对象存储Key',
|
||||
minio_url text null comment 'MinIO访问链接',
|
||||
oss_url text null comment '阿里云OSS内部备份链接',
|
||||
content_type varchar(128) null comment '文件Content-Type',
|
||||
file_size bigint unsigned null comment '文件大小,单位字节',
|
||||
minio_upload_status tinyint unsigned default 0 not null comment 'MinIO上传状态:0-PENDING,1-SUCCEEDED,2-FAILED',
|
||||
oss_upload_status tinyint unsigned default 0 not null comment 'OSS上传状态:0-PENDING,1-SUCCEEDED,2-FAILED',
|
||||
oss_retry_count int unsigned default 0 not null comment 'OSS备份重试次数',
|
||||
oss_last_error varchar(500) null comment '最近一次OSS备份失败原因',
|
||||
oss_uploaded_at datetime null comment 'OSS备份成功时间',
|
||||
oss_last_retry_time datetime null comment '最近一次OSS备份重试时间',
|
||||
create_time datetime default CURRENT_TIMESTAMP not null comment '文件上传时间',
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '文件更新时间',
|
||||
status tinyint unsigned default 1 null comment '文件状态:1-可用,0-不可用,2-回收站',
|
||||
@@ -288,6 +299,10 @@ create index idx_status
|
||||
on t_object_storage_file (status)
|
||||
comment '按文件状态查询的索引';
|
||||
|
||||
create index idx_object_storage_file_oss_retry
|
||||
on t_object_storage_file (oss_upload_status, minio_upload_status, status)
|
||||
comment 'OSS备份失败重试扫描索引';
|
||||
|
||||
-- auto-generated definition
|
||||
create table t_order
|
||||
(
|
||||
@@ -924,6 +939,25 @@ CALL sp_add_column_if_not_exists('t_balance', 'total_recharge_amount', 'decimal(
|
||||
CALL sp_add_column_if_not_exists('t_balance', 'last_recharge_time', 'datetime NULL COMMENT ''最近一次充值时间''');
|
||||
CALL sp_add_column_if_not_exists('t_balance', 'update_time', 'datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT ''更新时间''');
|
||||
|
||||
CALL sp_add_column_if_not_exists('t_object_storage_file', 'object_name', 'varchar(512) NULL COMMENT ''对象存储Key''');
|
||||
CALL sp_add_column_if_not_exists('t_object_storage_file', 'minio_url', 'text NULL COMMENT ''MinIO访问链接''');
|
||||
CALL sp_add_column_if_not_exists('t_object_storage_file', 'oss_url', 'text NULL COMMENT ''阿里云OSS内部备份链接''');
|
||||
CALL sp_add_column_if_not_exists('t_object_storage_file', 'content_type', 'varchar(128) NULL COMMENT ''文件Content-Type''');
|
||||
CALL sp_add_column_if_not_exists('t_object_storage_file', 'file_size', 'bigint unsigned NULL COMMENT ''文件大小,单位字节''');
|
||||
CALL sp_add_column_if_not_exists('t_object_storage_file', 'minio_upload_status', 'tinyint unsigned NOT NULL DEFAULT 0 COMMENT ''MinIO上传状态:0-PENDING,1-SUCCEEDED,2-FAILED''');
|
||||
CALL sp_add_column_if_not_exists('t_object_storage_file', 'oss_upload_status', 'tinyint unsigned NOT NULL DEFAULT 0 COMMENT ''OSS上传状态:0-PENDING,1-SUCCEEDED,2-FAILED''');
|
||||
CALL sp_add_column_if_not_exists('t_object_storage_file', 'oss_retry_count', 'int unsigned NOT NULL DEFAULT 0 COMMENT ''OSS备份重试次数''');
|
||||
CALL sp_add_column_if_not_exists('t_object_storage_file', 'oss_last_error', 'varchar(500) NULL COMMENT ''最近一次OSS备份失败原因''');
|
||||
CALL sp_add_column_if_not_exists('t_object_storage_file', 'oss_uploaded_at', 'datetime NULL COMMENT ''OSS备份成功时间''');
|
||||
CALL sp_add_column_if_not_exists('t_object_storage_file', 'oss_last_retry_time', 'datetime NULL COMMENT ''最近一次OSS备份重试时间''');
|
||||
UPDATE t_object_storage_file
|
||||
SET minio_url = COALESCE(minio_url, file_url),
|
||||
minio_upload_status = CASE WHEN minio_upload_status IS NULL OR minio_upload_status = 0 THEN 1 ELSE minio_upload_status END,
|
||||
oss_upload_status = COALESCE(oss_upload_status, 0),
|
||||
oss_retry_count = COALESCE(oss_retry_count, 0)
|
||||
WHERE status = 1;
|
||||
CALL sp_add_index_if_not_exists('t_object_storage_file', 'idx_object_storage_file_oss_retry', '(`oss_upload_status`, `minio_upload_status`, `status`)');
|
||||
|
||||
UPDATE t_balance
|
||||
SET total_recharge_amount = COALESCE(total_recharge_amount, 0.00)
|
||||
WHERE total_recharge_amount IS NULL;
|
||||
|
||||
+6
@@ -18,6 +18,7 @@ import com.xiaowang.yuminailcore.modules.product.mapper.ProductMapper;
|
||||
import com.xiaowang.yuminailcore.modules.shop.mapper.ShopMapper;
|
||||
import com.xiaowang.yuminailcore.modules.user.mapper.UserMapper;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.ObjectStorageFileService;
|
||||
import com.xiaowang.yuminailcore.modules.file.support.ObjectStorageUrlSupport;
|
||||
import com.xiaowang.yuminailcore.modules.shop.support.UserShopBindingSupport;
|
||||
import com.xiaowang.yuminailcore.modules.artist.vo.NailArtistAvailabilityVO;
|
||||
import com.xiaowang.yuminailcore.modules.artist.vo.NailArtistProfileVO;
|
||||
@@ -63,6 +64,8 @@ class NailArtistInfoServiceImplTest {
|
||||
@Mock
|
||||
private ObjectStorageFileService objectStorageFileService;
|
||||
@Mock
|
||||
private ObjectStorageUrlSupport objectStorageUrlSupport;
|
||||
@Mock
|
||||
private ArtistScheduleMapper artistScheduleMapper;
|
||||
@Mock
|
||||
private AppointmentReservationMapper appointmentReservationMapper;
|
||||
@@ -82,9 +85,12 @@ class NailArtistInfoServiceImplTest {
|
||||
ReflectionTestUtils.setField(service, "orderItemMapper", orderItemMapper);
|
||||
ReflectionTestUtils.setField(service, "orderArtistReviewMapper", orderArtistReviewMapper);
|
||||
ReflectionTestUtils.setField(service, "objectStorageFileService", objectStorageFileService);
|
||||
ReflectionTestUtils.setField(service, "objectStorageUrlSupport", objectStorageUrlSupport);
|
||||
ReflectionTestUtils.setField(service, "artistScheduleMapper", artistScheduleMapper);
|
||||
ReflectionTestUtils.setField(service, "appointmentReservationMapper", appointmentReservationMapper);
|
||||
when(userShopBindingSupport.listShopOptionsByUserId(any(), anyBoolean(), anyBoolean())).thenReturn(List.of());
|
||||
when(objectStorageUrlSupport.toAccessibleUrl(any(ObjectStorageFileVO.class)))
|
||||
.thenAnswer(invocation -> invocation.getArgument(0, ObjectStorageFileVO.class).getFileUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.xiaowang.yuminailcore.modules.file;
|
||||
|
||||
import com.xiaowang.yuminailcore.config.RabbitMQConfig;
|
||||
import com.xiaowang.yuminailcore.modules.file.config.AliyunOssConfig;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class FileOssBackupConfigurationTest {
|
||||
|
||||
@Test
|
||||
void rabbitMqConfigExposesDurableOssBackupRouteConstants() {
|
||||
assertThat(RabbitMQConfig.FILE_OSS_BACKUP_EXCHANGE).isEqualTo("yuminail.file.oss.backup.exchange");
|
||||
assertThat(RabbitMQConfig.FILE_OSS_BACKUP_QUEUE).isEqualTo("yuminail.file.oss.backup.queue");
|
||||
assertThat(RabbitMQConfig.FILE_OSS_BACKUP_ROUTING_KEY).isEqualTo("yuminail.file.oss.backup");
|
||||
}
|
||||
|
||||
@Test
|
||||
void aliyunOssConfigUsesPrivateBucketDefaults() {
|
||||
AliyunOssConfig config = new AliyunOssConfig();
|
||||
|
||||
assertThat(config.getBucketName()).isEqualTo("fingertipdesigner");
|
||||
assertThat(config.getSignedUrlExpireMinutes()).isEqualTo(30);
|
||||
}
|
||||
}
|
||||
+12
-13
@@ -1,17 +1,18 @@
|
||||
package com.xiaowang.yuminailcore.modules.file.controller.front;
|
||||
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.modules.product.mapper.EffectDiagramMapper;
|
||||
import com.xiaowang.yuminailcore.modules.product.mapper.ProductMapper;
|
||||
import com.xiaowang.yuminailcore.modules.shop.mapper.ShopMapper;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.MinioService;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.ObjectStorageFileService;
|
||||
import com.xiaowang.yuminailcore.modules.file.support.ObjectStorageUrlSupport;
|
||||
import com.xiaowang.yuminailcore.modules.file.vo.ObjectStorageFileVO;
|
||||
import com.xiaowang.yuminailcore.modules.product.mapper.EffectDiagramMapper;
|
||||
import com.xiaowang.yuminailcore.modules.product.mapper.ProductMapper;
|
||||
import com.xiaowang.yuminailcore.modules.shop.mapper.ShopMapper;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -20,7 +21,7 @@ import static org.mockito.Mockito.when;
|
||||
class FrontendFileControllerTest {
|
||||
|
||||
private ObjectStorageFileService objectStorageFileService;
|
||||
private MinioService minioService;
|
||||
private ObjectStorageUrlSupport objectStorageUrlSupport;
|
||||
private ProductMapper productMapper;
|
||||
private ShopMapper shopMapper;
|
||||
private EffectDiagramMapper effectDiagramMapper;
|
||||
@@ -29,20 +30,17 @@ class FrontendFileControllerTest {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
objectStorageFileService = mock(ObjectStorageFileService.class);
|
||||
minioService = mock(MinioService.class);
|
||||
ObjectStorageUrlSupport objectStorageUrlSupport = mock(ObjectStorageUrlSupport.class);
|
||||
objectStorageUrlSupport = mock(ObjectStorageUrlSupport.class);
|
||||
productMapper = mock(ProductMapper.class);
|
||||
shopMapper = mock(ShopMapper.class);
|
||||
effectDiagramMapper = mock(EffectDiagramMapper.class);
|
||||
controller = new FrontendFileController(
|
||||
objectStorageFileService,
|
||||
minioService,
|
||||
objectStorageUrlSupport,
|
||||
productMapper,
|
||||
shopMapper,
|
||||
effectDiagramMapper
|
||||
);
|
||||
when(objectStorageUrlSupport.extractObjectName("https://cdn.test/public/a.png")).thenReturn("public/a.png");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -56,16 +54,17 @@ class FrontendFileControllerTest {
|
||||
Result<String> result = controller.getSignedUrl(12L, 60);
|
||||
|
||||
assertThat(result.getCode()).isNotEqualTo(200);
|
||||
assertThat(result.getMessage()).contains("文件不可公开访问");
|
||||
verify(minioService, never()).getPresignedUrl(org.mockito.ArgumentMatchers.anyString(), org.mockito.ArgumentMatchers.anyInt());
|
||||
verify(objectStorageUrlSupport, never()).toAccessibleUrl(any(ObjectStorageFileVO.class), anyInt());
|
||||
verify(objectStorageUrlSupport, never()).getSignedUrlOrThrow(any(ObjectStorageFileVO.class), anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getSignedUrlAllowsPublicProductImageReference() throws Exception {
|
||||
ObjectStorageFileVO file = file();
|
||||
file.setObjectName("public/a.png");
|
||||
when(objectStorageFileService.getObjectStorageFileById(12L)).thenReturn(file);
|
||||
when(productMapper.countPublicImageReference(12L)).thenReturn(1L);
|
||||
when(minioService.getPresignedUrl("public/a.png", 30)).thenReturn("https://signed.test/public/a.png");
|
||||
when(objectStorageUrlSupport.getSignedUrlOrThrow(file, 30)).thenReturn("https://signed.test/public/a.png");
|
||||
|
||||
Result<String> result = controller.getSignedUrl(12L, 30);
|
||||
|
||||
@@ -84,7 +83,7 @@ class FrontendFileControllerTest {
|
||||
|
||||
assertThat(result.getCode()).isEqualTo(200);
|
||||
assertThat(result.getData()).isEqualTo("https://acceptance.local/images/public-a.png");
|
||||
verify(minioService, never()).getPresignedUrl(org.mockito.ArgumentMatchers.anyString(), org.mockito.ArgumentMatchers.anyInt());
|
||||
verify(objectStorageUrlSupport, never()).getSignedUrlOrThrow(any(ObjectStorageFileVO.class), anyInt());
|
||||
}
|
||||
|
||||
private ObjectStorageFileVO file() {
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.xiaowang.yuminailcore.modules.file.scheduler;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.xiaowang.yuminailcore.modules.file.entity.ObjectStorageFileDO;
|
||||
import com.xiaowang.yuminailcore.modules.file.mapper.ObjectStorageFileMapper;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.OssBackupService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class OssBackupRetrySchedulerTest {
|
||||
|
||||
private ObjectStorageFileMapper objectStorageFileMapper;
|
||||
private OssBackupService ossBackupService;
|
||||
private OssBackupRetryScheduler scheduler;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
objectStorageFileMapper = mock(ObjectStorageFileMapper.class);
|
||||
ossBackupService = mock(OssBackupService.class);
|
||||
scheduler = new OssBackupRetryScheduler(objectStorageFileMapper, ossBackupService);
|
||||
}
|
||||
|
||||
@Test
|
||||
void retryPendingOrFailedBackupsScansRetryableFilesAndDispatchesBackup() {
|
||||
ObjectStorageFileDO pending = new ObjectStorageFileDO();
|
||||
pending.setId(1L);
|
||||
ObjectStorageFileDO failed = new ObjectStorageFileDO();
|
||||
failed.setId(2L);
|
||||
when(objectStorageFileMapper.selectList(any())).thenReturn(List.of(pending, failed));
|
||||
|
||||
scheduler.retryPendingOrFailedBackups();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ArgumentCaptor<Wrapper<ObjectStorageFileDO>> captor = ArgumentCaptor.forClass(Wrapper.class);
|
||||
verify(objectStorageFileMapper).selectList(captor.capture());
|
||||
assertThat(captor.getValue()).isNotNull();
|
||||
verify(ossBackupService).backupFileToOss(1L);
|
||||
verify(ossBackupService).backupFileToOss(2L);
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package com.xiaowang.yuminailcore.modules.file.service.impl;
|
||||
|
||||
import com.xiaowang.yuminailcore.config.AppCacheProperties;
|
||||
import com.xiaowang.yuminailcore.modules.file.dto.ObjectStorageFileDTO;
|
||||
import com.xiaowang.yuminailcore.modules.file.entity.ObjectStorageFileDO;
|
||||
import com.xiaowang.yuminailcore.modules.file.mapper.ObjectStorageFileMapper;
|
||||
import com.xiaowang.yuminailcore.modules.file.mq.OssBackupMessagePublisher;
|
||||
import com.xiaowang.yuminailcore.support.cache.MultiLevelCacheService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class ObjectStorageFileServiceImplTest {
|
||||
|
||||
private ObjectStorageFileMapper objectStorageFileMapper;
|
||||
private OssBackupMessagePublisher ossBackupMessagePublisher;
|
||||
private ObjectStorageFileServiceImpl service;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
objectStorageFileMapper = mock(ObjectStorageFileMapper.class);
|
||||
MultiLevelCacheService multiLevelCacheService = mock(MultiLevelCacheService.class);
|
||||
AppCacheProperties appCacheProperties = new AppCacheProperties();
|
||||
ossBackupMessagePublisher = mock(OssBackupMessagePublisher.class);
|
||||
service = new ObjectStorageFileServiceImpl(
|
||||
objectStorageFileMapper,
|
||||
multiLevelCacheService,
|
||||
appCacheProperties,
|
||||
ossBackupMessagePublisher
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void createObjectStorageFilePublishesOssBackupMessageAfterMinioUploadSucceeded() {
|
||||
when(objectStorageFileMapper.insert(any(ObjectStorageFileDO.class))).thenAnswer(invocation -> {
|
||||
ObjectStorageFileDO file = invocation.getArgument(0);
|
||||
file.setId(66L);
|
||||
return 1;
|
||||
});
|
||||
|
||||
ObjectStorageFileDTO dto = new ObjectStorageFileDTO();
|
||||
dto.setFileName("a.png");
|
||||
dto.setFileUrl("http://127.0.0.1:9000/yuminail/product/a.png");
|
||||
dto.setObjectName("product/a.png");
|
||||
dto.setMinioUrl(dto.getFileUrl());
|
||||
dto.setContentType("image/png");
|
||||
dto.setFileSize(3L);
|
||||
dto.setStatus(1);
|
||||
dto.setMinioUploadStatus(1);
|
||||
dto.setOssUploadStatus(0);
|
||||
dto.setOssRetryCount(0);
|
||||
|
||||
Long fileId = service.createObjectStorageFile(dto);
|
||||
|
||||
assertThat(fileId).isEqualTo(66L);
|
||||
ArgumentCaptor<ObjectStorageFileDO> captor = ArgumentCaptor.forClass(ObjectStorageFileDO.class);
|
||||
verify(objectStorageFileMapper).insert(captor.capture());
|
||||
assertThat(captor.getValue().getObjectName()).isEqualTo("product/a.png");
|
||||
assertThat(captor.getValue().getMinioUploadStatus()).isEqualTo(1);
|
||||
assertThat(captor.getValue().getOssUploadStatus()).isEqualTo(0);
|
||||
verify(ossBackupMessagePublisher).publish(66L);
|
||||
}
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package com.xiaowang.yuminailcore.modules.file.service.impl;
|
||||
|
||||
import com.xiaowang.yuminailcore.modules.file.entity.ObjectStorageFileDO;
|
||||
import com.xiaowang.yuminailcore.modules.file.mapper.ObjectStorageFileMapper;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.AliyunOssService;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.MinioService;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.ObjectStorageFileService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class OssBackupServiceImplTest {
|
||||
|
||||
private ObjectStorageFileMapper objectStorageFileMapper;
|
||||
private MinioService minioService;
|
||||
private AliyunOssService aliyunOssService;
|
||||
private ObjectStorageFileService objectStorageFileService;
|
||||
private OssBackupServiceImpl service;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
objectStorageFileMapper = mock(ObjectStorageFileMapper.class);
|
||||
minioService = mock(MinioService.class);
|
||||
aliyunOssService = mock(AliyunOssService.class);
|
||||
objectStorageFileService = mock(ObjectStorageFileService.class);
|
||||
service = new OssBackupServiceImpl(objectStorageFileMapper, minioService, aliyunOssService, objectStorageFileService);
|
||||
}
|
||||
|
||||
@Test
|
||||
void backupFileToOssMarksFileSucceededAfterUploadingMinioStreamToOss() throws Exception {
|
||||
ObjectStorageFileDO file = activeMinioFile();
|
||||
byte[] bytes = "abc".getBytes(StandardCharsets.UTF_8);
|
||||
when(objectStorageFileMapper.selectById(88L)).thenReturn(file);
|
||||
when(minioService.downloadFile("product/a.png")).thenReturn(new ByteArrayInputStream(bytes));
|
||||
when(aliyunOssService.uploadStream(eq("product/a.png"), any(), eq(3L), eq("image/png")))
|
||||
.thenReturn("oss://fingertipdesigner/product/a.png");
|
||||
|
||||
service.backupFileToOss(88L);
|
||||
|
||||
ArgumentCaptor<ObjectStorageFileDO> captor = ArgumentCaptor.forClass(ObjectStorageFileDO.class);
|
||||
verify(objectStorageFileMapper).updateById(captor.capture());
|
||||
ObjectStorageFileDO updated = captor.getValue();
|
||||
assertThat(updated.getId()).isEqualTo(88L);
|
||||
assertThat(updated.getOssUrl()).isEqualTo("oss://fingertipdesigner/product/a.png");
|
||||
assertThat(updated.getOssUploadStatus()).isEqualTo(1);
|
||||
assertThat(updated.getOssUploadedAt()).isNotNull();
|
||||
assertThat(updated.getOssLastError()).isNull();
|
||||
verify(objectStorageFileService).evictObjectStorageFileCache(88L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void backupFileToOssMarksFileFailedAndTruncatesErrorWhenOssUploadFails() throws Exception {
|
||||
ObjectStorageFileDO file = activeMinioFile();
|
||||
file.setOssRetryCount(2);
|
||||
when(objectStorageFileMapper.selectById(88L)).thenReturn(file);
|
||||
when(minioService.downloadFile("product/a.png")).thenReturn(new ByteArrayInputStream(new byte[]{1}));
|
||||
when(aliyunOssService.uploadStream(eq("product/a.png"), any(), eq(3L), eq("image/png")))
|
||||
.thenThrow(new IllegalStateException("x".repeat(700)));
|
||||
|
||||
service.backupFileToOss(88L);
|
||||
|
||||
ArgumentCaptor<ObjectStorageFileDO> captor = ArgumentCaptor.forClass(ObjectStorageFileDO.class);
|
||||
verify(objectStorageFileMapper).updateById(captor.capture());
|
||||
ObjectStorageFileDO updated = captor.getValue();
|
||||
assertThat(updated.getOssUploadStatus()).isEqualTo(2);
|
||||
assertThat(updated.getOssRetryCount()).isEqualTo(3);
|
||||
assertThat(updated.getOssLastRetryTime()).isNotNull();
|
||||
assertThat(updated.getOssLastError()).hasSizeLessThanOrEqualTo(500);
|
||||
verify(objectStorageFileService).evictObjectStorageFileCache(88L);
|
||||
}
|
||||
|
||||
private ObjectStorageFileDO activeMinioFile() {
|
||||
ObjectStorageFileDO file = new ObjectStorageFileDO();
|
||||
file.setId(88L);
|
||||
file.setStatus(1);
|
||||
file.setObjectName("product/a.png");
|
||||
file.setMinioUploadStatus(1);
|
||||
file.setOssUploadStatus(0);
|
||||
file.setContentType("image/png");
|
||||
file.setFileSize(3L);
|
||||
return file;
|
||||
}
|
||||
}
|
||||
+71
-5
@@ -1,41 +1,107 @@
|
||||
package com.xiaowang.yuminailcore.modules.file.support;
|
||||
|
||||
import com.xiaowang.yuminailcore.config.MinioConfig;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.AliyunOssService;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.MinioService;
|
||||
import com.xiaowang.yuminailcore.modules.file.vo.ObjectStorageFileVO;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
class ObjectStorageUrlSupportTest {
|
||||
|
||||
private MinioService minioService;
|
||||
private AliyunOssService aliyunOssService;
|
||||
private ObjectStorageUrlSupport support;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
minioService = mock(MinioService.class);
|
||||
aliyunOssService = mock(AliyunOssService.class);
|
||||
|
||||
MinioConfig config = new MinioConfig();
|
||||
config.setEndpoint("http://127.0.0.1:9000");
|
||||
config.setBucketName("yuminail");
|
||||
support = new ObjectStorageUrlSupport(minioService, config);
|
||||
|
||||
support = new ObjectStorageUrlSupport(minioService, config, aliyunOssService);
|
||||
}
|
||||
|
||||
@Test
|
||||
void toAccessibleUrlFallsBackToOriginalExternalUrlWhenObjectNameCannotBeExtracted() {
|
||||
String externalUrl = "https://acceptance.local/assets/作品图.jpg";
|
||||
String externalUrl = "https://acceptance.local/assets/product-a.jpg";
|
||||
|
||||
String result = support.toAccessibleUrl(externalUrl);
|
||||
|
||||
assertThat(result).isEqualTo(externalUrl);
|
||||
verifyNoInteractions(minioService);
|
||||
verifyNoInteractions(minioService, aliyunOssService);
|
||||
}
|
||||
|
||||
@Test
|
||||
void extractObjectNameStillAcceptsRawObjectName() {
|
||||
assertThat(support.extractObjectName("product/作品图.jpg?x=1")).isEqualTo("product/作品图.jpg");
|
||||
assertThat(support.extractObjectName("product/a.jpg?x=1")).isEqualTo("product/a.jpg");
|
||||
}
|
||||
|
||||
@Test
|
||||
void toAccessibleUrlReturnsNullInsteadOfRawUrlWhenStringObjectSigningFails() throws Exception {
|
||||
when(minioService.getPresignedUrl("product/a.jpg", 60)).thenThrow(new IllegalStateException("minio down"));
|
||||
|
||||
String result = support.toAccessibleUrl("http://127.0.0.1:9000/yuminail/product/a.jpg");
|
||||
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void toAccessibleUrlFallsBackToOssSignedUrlWhenMinioSigningFailsAndBackupSucceeded() throws Exception {
|
||||
ObjectStorageFileVO file = new ObjectStorageFileVO();
|
||||
file.setId(12L);
|
||||
file.setFileUrl("http://127.0.0.1:9000/yuminail/product/a.png");
|
||||
file.setMinioUrl("http://127.0.0.1:9000/yuminail/product/a.png");
|
||||
file.setObjectName("product/a.png");
|
||||
file.setOssUploadStatus(1);
|
||||
|
||||
when(minioService.getPresignedUrl("product/a.png", 60)).thenThrow(new IllegalStateException("minio down"));
|
||||
when(aliyunOssService.getPresignedUrl("product/a.png")).thenReturn("https://oss-signed.test/product/a.png");
|
||||
|
||||
String result = support.toAccessibleUrl(file);
|
||||
|
||||
assertThat(result).isEqualTo("https://oss-signed.test/product/a.png");
|
||||
}
|
||||
|
||||
@Test
|
||||
void toAccessibleUrlReturnsNullInsteadOfRawObjectStorageUrlWhenBothBackendsAreUnavailable() throws Exception {
|
||||
ObjectStorageFileVO file = new ObjectStorageFileVO();
|
||||
file.setId(12L);
|
||||
file.setFileUrl("http://127.0.0.1:9000/yuminail/product/a.png");
|
||||
file.setMinioUrl("http://127.0.0.1:9000/yuminail/product/a.png");
|
||||
file.setObjectName("product/a.png");
|
||||
file.setOssUploadStatus(1);
|
||||
|
||||
when(minioService.getPresignedUrl("product/a.png", 60)).thenThrow(new IllegalStateException("minio down"));
|
||||
when(aliyunOssService.getPresignedUrl("product/a.png")).thenThrow(new IllegalStateException("oss down"));
|
||||
|
||||
String result = support.toAccessibleUrl(file);
|
||||
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void getSignedUrlOrThrowReportsClearFailureWhenBothBackendsAreUnavailable() throws Exception {
|
||||
ObjectStorageFileVO file = new ObjectStorageFileVO();
|
||||
file.setId(12L);
|
||||
file.setFileUrl("http://127.0.0.1:9000/yuminail/product/a.png");
|
||||
file.setObjectName("product/a.png");
|
||||
file.setOssUploadStatus(1);
|
||||
|
||||
when(minioService.getPresignedUrl("product/a.png", 20)).thenThrow(new IllegalStateException("minio down"));
|
||||
when(aliyunOssService.getPresignedUrl("product/a.png")).thenThrow(new IllegalStateException("oss down"));
|
||||
|
||||
assertThatThrownBy(() -> support.getSignedUrlOrThrow(file, 20))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("No available object storage signed URL");
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -8,6 +8,7 @@ import com.xiaowang.yuminailcore.modules.product.mapper.ProductMapper;
|
||||
import com.xiaowang.yuminailcore.modules.shop.mapper.ShopMapper;
|
||||
import com.xiaowang.yuminailcore.modules.product.mapper.TagMapper;
|
||||
import com.xiaowang.yuminailcore.modules.file.service.ObjectStorageFileService;
|
||||
import com.xiaowang.yuminailcore.modules.file.support.ObjectStorageUrlSupport;
|
||||
import com.xiaowang.yuminailcore.modules.artist.support.BookableArtistSupport;
|
||||
import com.xiaowang.yuminailcore.support.cache.MultiLevelCacheService;
|
||||
import com.xiaowang.yuminailcore.modules.product.vo.ProductVO;
|
||||
@@ -36,6 +37,9 @@ class ProductServiceImplTest {
|
||||
@Mock
|
||||
private ObjectStorageFileService objectStorageFileService;
|
||||
|
||||
@Mock
|
||||
private ObjectStorageUrlSupport objectStorageUrlSupport;
|
||||
|
||||
@Mock
|
||||
private CouponMapper couponMapper;
|
||||
|
||||
@@ -59,6 +63,7 @@ class ProductServiceImplTest {
|
||||
productService = new ProductServiceImpl(
|
||||
productMapper,
|
||||
objectStorageFileService,
|
||||
objectStorageUrlSupport,
|
||||
couponMapper,
|
||||
shopMapper,
|
||||
tagMapper,
|
||||
|
||||
+2
@@ -96,6 +96,8 @@ class ShopServiceImplTest {
|
||||
);
|
||||
when(objectStorageUrlSupport.toAccessibleUrl(anyString()))
|
||||
.thenAnswer(invocation -> invocation.getArgument(0, String.class));
|
||||
when(objectStorageUrlSupport.toAccessibleUrl(any(ObjectStorageFileVO.class)))
|
||||
.thenAnswer(invocation -> invocation.getArgument(0, ObjectStorageFileVO.class).getFileUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+25
@@ -101,4 +101,29 @@ class YumiNailSqlSchemaTest {
|
||||
assertThat(sql).contains("CALL sp_add_column_if_not_exists('t_user', 'contact_phone'");
|
||||
assertThat(sql).contains("CALL sp_add_column_if_not_exists('t_user', 'wechat_qr_code'");
|
||||
}
|
||||
|
||||
@Test
|
||||
void objectStorageFileOssBackupColumnsAreSeeded() throws Exception {
|
||||
String sql = Files.readString(Path.of("src/main/resources/files/YumiNail.sql"));
|
||||
String initSql = Files.readString(Path.of("../scripts/sql/init/YumiNail.sql"));
|
||||
|
||||
assertThat(sql).contains("object_name");
|
||||
assertThat(sql).contains("minio_url");
|
||||
assertThat(sql).contains("oss_url");
|
||||
assertThat(sql).contains("content_type");
|
||||
assertThat(sql).contains("file_size");
|
||||
assertThat(sql).contains("minio_upload_status");
|
||||
assertThat(sql).contains("oss_upload_status");
|
||||
assertThat(sql).contains("oss_retry_count");
|
||||
assertThat(sql).contains("oss_last_error");
|
||||
assertThat(sql).contains("oss_uploaded_at");
|
||||
assertThat(sql).contains("oss_last_retry_time");
|
||||
assertThat(sql).contains("CALL sp_add_column_if_not_exists('t_object_storage_file', 'object_name'");
|
||||
assertThat(sql).contains("CALL sp_add_index_if_not_exists('t_object_storage_file', 'idx_object_storage_file_oss_retry'");
|
||||
assertThat(initSql).contains("object_name");
|
||||
assertThat(initSql).contains("minio_upload_status");
|
||||
assertThat(initSql).contains("oss_upload_status");
|
||||
assertThat(initSql).contains("CALL sp_add_column_if_not_exists('t_object_storage_file', 'object_name'");
|
||||
assertThat(initSql).contains("CALL sp_add_index_if_not_exists('t_object_storage_file', 'idx_object_storage_file_oss_retry'");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user