feat: 优化

This commit is contained in:
2026-03-04 02:13:16 +08:00
parent aa06782953
commit 7f5d9d9f19
17 changed files with 1958 additions and 1727 deletions

View File

@@ -52,4 +52,11 @@ public interface FileApi {
String presignGetUrl(@NotEmpty(message = "URL 不能为空") String url,
Integer expirationSeconds);
/**
* 获取主文件配置的自定义域名CDN域名
*
* @return 自定义域名,如 https://oss.muyetools.cn
*/
String getMasterFileDomain();
}

View File

@@ -1,5 +1,9 @@
package cn.iocoder.yudao.module.infra.api.file;
import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClient;
import cn.iocoder.yudao.module.infra.framework.file.core.client.s3.S3FileClient;
import cn.iocoder.yudao.module.infra.framework.file.core.client.s3.S3FileClientConfig;
import cn.iocoder.yudao.module.infra.service.file.FileConfigService;
import cn.iocoder.yudao.module.infra.service.file.FileService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
@@ -17,6 +21,9 @@ public class FileApiImpl implements FileApi {
@Resource
private FileService fileService;
@Resource
private FileConfigService fileConfigService;
@Override
public String createFile(byte[] content, String name, String directory, String type) {
return fileService.createFile(content, name, directory, type);
@@ -27,4 +34,14 @@ public class FileApiImpl implements FileApi {
return fileService.presignGetUrl(url, expirationSeconds);
}
@Override
public String getMasterFileDomain() {
FileClient client = fileConfigService.getMasterFileClient();
if (client instanceof S3FileClient) {
S3FileClient s3Client = (S3FileClient) client;
return s3Client.getConfig().getDomain();
}
return null;
}
}

View File

@@ -54,6 +54,11 @@ public abstract class AbstractFileClient<Config extends FileClientConfig> implem
return id;
}
@Override
public Config getConfig() {
return config;
}
/**
* 格式化文件的 URL 访问地址
* 使用场景local、ftp、db通过 FileController 的 getFile 来获取文件内容

View File

@@ -74,4 +74,11 @@ public interface FileClient {
throw new UnsupportedOperationException("不支持的操作");
}
/**
* 获取文件配置
*
* @return 文件配置
*/
FileClientConfig getConfig();
}