mirror of
https://github.com/zfile-dev/zfile.git
synced 2025-04-19 05:34:52 +00:00
🔨 重构代码, 将每个存储策略的表单设置改为 Java 配置
This commit is contained in:
@@ -21,9 +21,9 @@ import java.util.Objects;
|
||||
* @author zhaojun
|
||||
*/
|
||||
@Service
|
||||
public class S3ServiceImpl extends AbstractS3BaseFileService implements BaseFileService {
|
||||
public abstract class AbstractS3Service extends AbstractS3BaseFileService implements BaseFileService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(S3ServiceImpl.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(AbstractS3Service.class);
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
@@ -65,4 +65,4 @@ public class S3ServiceImpl extends AbstractS3BaseFileService implements BaseFile
|
||||
return StorageTypeEnum.S3;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import com.amazonaws.auth.AWSStaticCredentialsProvider;
|
||||
import com.amazonaws.auth.BasicAWSCredentials;
|
||||
import com.amazonaws.client.builder.AwsClientBuilder;
|
||||
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
|
||||
import im.zhaojun.zfile.model.dto.StorageStrategyDTO;
|
||||
import im.zhaojun.zfile.model.entity.StorageConfig;
|
||||
import im.zhaojun.zfile.model.constant.StorageConfigConstant;
|
||||
import im.zhaojun.zfile.model.enums.StorageTypeEnum;
|
||||
@@ -14,6 +15,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -60,4 +63,15 @@ public class AliyunServiceImpl extends AbstractS3BaseFileService implements Base
|
||||
return StorageTypeEnum.ALIYUN;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public List<StorageConfig> storageStrategyList() {
|
||||
return new ArrayList<StorageConfig>() {{
|
||||
add(new StorageConfig("accessKey", "AccessKey"));
|
||||
add(new StorageConfig("secretKey", "SecretKey"));
|
||||
add(new StorageConfig("bucket-name", "Bucket 名称"));
|
||||
add(new StorageConfig("domain", "Bucket 域名 / CDN 加速域名"));
|
||||
add(new StorageConfig("endPoint", "区域"));
|
||||
add(new StorageConfig("base-path", "基路径"));
|
||||
}};
|
||||
}
|
||||
}
|
||||
@@ -129,4 +129,16 @@ public class FtpServiceImpl extends AbstractBaseFileService implements BaseFileS
|
||||
fileItemDTO.setUrl(getDownloadUrl(path));
|
||||
return fileItemDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StorageConfig> storageStrategyList() {
|
||||
return new ArrayList<StorageConfig>() {{
|
||||
add(new StorageConfig("host", "域名或IP"));
|
||||
add(new StorageConfig("port", "端口"));
|
||||
add(new StorageConfig("username", "用户名"));
|
||||
add(new StorageConfig("password", "密码"));
|
||||
add(new StorageConfig("domain", "加速域名"));
|
||||
add(new StorageConfig("base-path", "基路径"));
|
||||
}};
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -60,4 +62,18 @@ public class HuaweiServiceImpl extends AbstractS3BaseFileService implements Base
|
||||
return StorageTypeEnum.HUAWEI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StorageConfig> storageStrategyList() {
|
||||
return new ArrayList<StorageConfig>() {{
|
||||
add(new StorageConfig("accessKey", "AccessKey"));
|
||||
add(new StorageConfig("secretKey", "SecretKey"));
|
||||
add(new StorageConfig("bucket-name", "云存储服务名称"));
|
||||
add(new StorageConfig("domain", "加速域名"));
|
||||
add(new StorageConfig("endPoint", "区域"));
|
||||
add(new StorageConfig("base-path", "基路径"));
|
||||
add(new StorageConfig("isPrivate", "是否是私有空间"));
|
||||
}};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -127,4 +127,11 @@ public class LocalServiceImpl extends AbstractBaseFileService implements BaseFil
|
||||
|
||||
return fileItemDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StorageConfig> storageStrategyList() {
|
||||
return new ArrayList<StorageConfig>() {{
|
||||
add(new StorageConfig("filePath", "文件路径"));
|
||||
}};
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -61,4 +63,16 @@ public class MinIOServiceImpl extends AbstractS3BaseFileService implements BaseF
|
||||
return StorageTypeEnum.MINIO;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public List<StorageConfig> storageStrategyList() {
|
||||
return new ArrayList<StorageConfig>() {{
|
||||
add(new StorageConfig("accessKey", "AccessKey"));
|
||||
add(new StorageConfig("secretKey", "SecretKey"));
|
||||
add(new StorageConfig("endPoint", "服务地址"));
|
||||
add(new StorageConfig("bucket-name", "存储空间名称"));
|
||||
add(new StorageConfig("base-path", "基路径"));
|
||||
add(new StorageConfig("isPrivate", "是否是私有空间"));
|
||||
}};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -96,4 +96,5 @@ public class OneDriveChinaServiceImpl extends AbstractOneDriveServiceBase implem
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -60,4 +62,17 @@ public class QiniuServiceImpl extends AbstractS3BaseFileService implements BaseF
|
||||
return StorageTypeEnum.QINIU;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StorageConfig> storageStrategyList() {
|
||||
return new ArrayList<StorageConfig>() {{
|
||||
add(new StorageConfig("accessKey", "AccessKey"));
|
||||
add(new StorageConfig("secretKey", "SecretKey"));
|
||||
add(new StorageConfig("bucket-name", "存储空间名称"));
|
||||
add(new StorageConfig("domain", "加速域名"));
|
||||
add(new StorageConfig("endPoint", "区域"));
|
||||
add(new StorageConfig("base-path", "基路径"));
|
||||
add(new StorageConfig("isPrivate", "是否是私有空间"));
|
||||
}};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -55,10 +57,21 @@ public class TencentServiceImpl extends AbstractS3BaseFileService implements Bas
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public StorageTypeEnum getStorageTypeEnum() {
|
||||
return StorageTypeEnum.TENCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StorageConfig> storageStrategyList() {
|
||||
return new ArrayList<StorageConfig>() {{
|
||||
add(new StorageConfig("secretId", "SecretId"));
|
||||
add(new StorageConfig("secretKey", "SecretKey"));
|
||||
add(new StorageConfig("bucket-name", "云存储服务名称"));
|
||||
add(new StorageConfig("domain", "加速域名"));
|
||||
add(new StorageConfig("endPoint", "区域"));
|
||||
add(new StorageConfig("base-path", "基路径"));
|
||||
add(new StorageConfig("isPrivate", "是否是私有空间"));
|
||||
}};
|
||||
}
|
||||
}
|
||||
@@ -128,4 +128,16 @@ public class UpYunServiceImpl extends AbstractBaseFileService implements BaseFil
|
||||
|
||||
throw new NotExistFileException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StorageConfig> storageStrategyList() {
|
||||
return new ArrayList<StorageConfig>() {{
|
||||
add(new StorageConfig("bucket-name", "云存储服务名称"));
|
||||
add(new StorageConfig("username", "操作员名称"));
|
||||
add(new StorageConfig("password", "操作员密码"));
|
||||
add(new StorageConfig("domain", "加速域名"));
|
||||
add(new StorageConfig("base-path", "基路径"));
|
||||
}};
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user