feat: add minio/ali oss
This commit is contained in:
@@ -8,23 +8,23 @@
|
||||
# 数据库连接信息
|
||||
jdbc:
|
||||
dbName: schisandra-cloud-storage
|
||||
tableName: schisandra_sys_log
|
||||
tableName: schisandra_oss_ali
|
||||
url: jdbc:mysql://1.95.0.111:3306/
|
||||
username: root
|
||||
password: LDQ20020618xxx
|
||||
driver: com.mysql.cj.jdbc.Driver
|
||||
|
||||
# 使用的模板与生成文件映射给关系
|
||||
mapperInfos: genCode/systemLogMapper.yml
|
||||
mapperInfos: genCode/ossMapper.yml
|
||||
|
||||
# 全局参数
|
||||
params:
|
||||
# 作者
|
||||
author: landaiqing
|
||||
# 模块
|
||||
module: system
|
||||
module: oss
|
||||
# controller 通用前缀
|
||||
api: /system/log
|
||||
api: /oss
|
||||
# 生成对象是否移除前缀
|
||||
removePre: false
|
||||
# 使用内置函数赋值给变量 FunctionUtils 中替换
|
||||
|
@@ -1,47 +0,0 @@
|
||||
package com.schisandra.oss.application.controller;
|
||||
|
||||
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||
import com.schisandra.oss.application.oss.utils.MinIOUtils;
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssConfigBO;
|
||||
import com.schisandra.oss.domain.service.impl.SchisandraOssConfigDomainService;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Classname SchisandraMinioOssController
|
||||
* @BelongsProject: schisandra-cloud-storage
|
||||
* @BelongsPackage: com.schisandra.oss.application.controller
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-05-13 00:04
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/oss/minio/")
|
||||
@Slf4j
|
||||
public class SchisandraMinioOssController {
|
||||
|
||||
@Resource
|
||||
private SchisandraOssConfigDomainService schisandraOssConfigDomainService;
|
||||
|
||||
@RequestMapping("init")
|
||||
@SneakyThrows
|
||||
public void init() {
|
||||
SchisandraOssConfigBO minio = schisandraOssConfigDomainService.getOssConfig(OssConstant.OssType.MINIO);
|
||||
if (ObjectUtils.isEmpty(minio)) {
|
||||
log.error("minio配置信息获取失败");
|
||||
}
|
||||
new MinIOUtils(minio.getEndpoint(), minio.getBucketName(), minio.getAccessKey(), minio.getSecretKey(), minio.getImgSize(), minio.getFileSize());
|
||||
}
|
||||
|
||||
@GetMapping("test")
|
||||
public void test(){
|
||||
System.out.println(MinIOUtils.getBasisUrl());
|
||||
}
|
||||
}
|
@@ -0,0 +1,239 @@
|
||||
package com.schisandra.oss.application.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import com.schisandra.oss.application.convert.SchisandraOssAliDTOConverter;
|
||||
import com.schisandra.oss.application.dto.SchisandraOssAliDTO;
|
||||
import com.schisandra.oss.common.entity.Result;
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||
import com.schisandra.oss.domain.service.SchisandraOssAliDomainService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* controller
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 20:45:32
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/oss/")
|
||||
@Slf4j
|
||||
public class SchisandraOssAliController {
|
||||
|
||||
@Resource
|
||||
private SchisandraOssAliDomainService schisandraOssAliDomainService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@RequestMapping("add")
|
||||
public Result<Boolean> add(@RequestBody SchisandraOssAliDTO schisandraOssAliDTO) {
|
||||
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SchisandraOssAliController.add.dto:{}", JSON.toJSONString(schisandraOssAliDTO));
|
||||
}
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getId(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUserId(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getEndpoint(), "OSS地址不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getAccessKeyId(), "AccessKey ID不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getAccessKeySecret(), "AccessKey Secret不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSecurityToken(), "security Token不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getBucketName(), "Bucket名称不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getBasePath(), "数据存储路径不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUserAgent(), "用户代理,指HTTP的User-Agent头。默认为aliyun-sdk-java。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getMaxErrorRetry(), "请求失败后最大的重试次数。默认3次。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getConnectionRequestTimeout(), "从连接池中获取连接的超时时间(单位:毫秒)。默认不超时。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getConnectionTimeout(), "建立连接的超时时间(单位:毫秒)。默认为50000毫秒。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSocketTimeout(), "Socket层传输数据的超时时间(单位:毫秒)。默认为50000毫秒。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getMaxConnections(), "允许打开的最大HTTP连接数。默认为1024不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getConnectionTTL(), "连接TTL (生存时间)。Http连接由连接管理器用TTL缓存。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUseReaper(), "是否使用com.aliyun.oss.common.comm.IdleConnectionReaper管理过期连接,默认开启不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getIdleConnectionTime(), "连接空闲超时时间,超时则关闭连接(单位:毫秒)。默认为60000毫秒。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProtocol(), "连接OSS所采用的协议(HTTP或HTTPS),默认为HTTP。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyHost(), "代理服务器主机地址。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyPort(), "代理服务器端口。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyUsername(), "代理服务器验证的用户名。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyPassword(), "代理服务器验证的密码。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyDomain(), "代理服务器的域,该域可以执行NTLM认证不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyWorkstation(), "代理主机的NTLM身份验证服务器不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSupportCname(), "是否支持CNAME作为Endpoint,默认支持CNAME。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCnameExcludeList(), "设置不可变排除的CName列表 ---- 任何以该列表中的项目结尾的域都不会进行Cname解析。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSldEnabled(), "是否开启二级域名(Second Level Domain)的访问方式,默认不开启。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getRequestTimeout(), "请求超时时间,单位:毫秒。默认情况下是5分钟。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getRequestTimeoutEnabled(), "是否启用请求超时校验。默认情况下,它是禁用的。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSlowRequestsThreshold(), "设置慢请求的延迟阈值。如果请求的延迟大于延迟,则将记录该请求。默认情况下,阈值为5分钟。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getDefaultHeaders(), "设置默认的http头。所有请求头将自动添加到每个请求中。如果在请求中也指定了相同的请求头,则默认的标头将被覆盖。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCrcCheckEnabled(), "是否在上传和下载时启用CRC校验,默认启用不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSignatureVersion(), "所有请求设置签名版本不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getTickOffset(), "设置OSS服务端时间和本地时间之间的差异,以毫秒为单位。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getRedirectEnable(), "是否开启HTTP重定向。 说明: Java SDK 3.10.1及以上版本支持设置是否开启HTTP重定向,默认开启。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getVerifySSLEnable(), "是否开启SSL证书校验。 * 说明: Java SDK 3.10.1及以上版本支持设置是否开启SSL证书校验,默认开启。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getLogConnectionPoolStats(), "是否开启日志记录连接池统计信息不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUseSystemPropertyValues(), "是否使用系统属性值不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getPartSize(), "分片大小,默认5MB不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getTaskNum(), "并发线程数,默认等于CPU的核数不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getStatus(), "状态不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getOpenAdvancedSetup(), "是否开启高级设置不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCreatedBy(), "创建人不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCreatedTime(), "创建时间不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUpdateTime(), "更新时间不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUpdateBy(), "更新人不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getIsDeleted(), "是否删除 0 未删除 1已删除不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getExtraJson(), "额外字段不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCreateBucket(), "当桶不存在,是否创建不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCheckBucket(), "启动检测桶,是否存在不能为空");
|
||||
SchisandraOssAliBO SchisandraOssAliBO = SchisandraOssAliDTOConverter.INSTANCE.convertDTOToBO(schisandraOssAliDTO);
|
||||
return Result.ok(schisandraOssAliDomainService.add(SchisandraOssAliBO));
|
||||
} catch (Exception e) {
|
||||
log.error("SchisandraOssAliController.register.error:{}", e.getMessage(), e);
|
||||
return Result.fail("新增失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("update")
|
||||
public Result<Boolean> update(@RequestBody SchisandraOssAliDTO schisandraOssAliDTO) {
|
||||
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SchisandraOssAliController.update.dto:{}", JSON.toJSONString(schisandraOssAliDTO));
|
||||
}
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getId(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUserId(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getEndpoint(), "OSS地址不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getAccessKeyId(), "AccessKey ID不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getAccessKeySecret(), "AccessKey Secret不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSecurityToken(), "security Token不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getBucketName(), "Bucket名称不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getBasePath(), "数据存储路径不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUserAgent(), "用户代理,指HTTP的User-Agent头。默认为aliyun-sdk-java。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getMaxErrorRetry(), "请求失败后最大的重试次数。默认3次。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getConnectionRequestTimeout(), "从连接池中获取连接的超时时间(单位:毫秒)。默认不超时。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getConnectionTimeout(), "建立连接的超时时间(单位:毫秒)。默认为50000毫秒。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSocketTimeout(), "Socket层传输数据的超时时间(单位:毫秒)。默认为50000毫秒。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getMaxConnections(), "允许打开的最大HTTP连接数。默认为1024不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getConnectionTTL(), "连接TTL (生存时间)。Http连接由连接管理器用TTL缓存。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUseReaper(), "是否使用com.aliyun.oss.common.comm.IdleConnectionReaper管理过期连接,默认开启不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getIdleConnectionTime(), "连接空闲超时时间,超时则关闭连接(单位:毫秒)。默认为60000毫秒。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProtocol(), "连接OSS所采用的协议(HTTP或HTTPS),默认为HTTP。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyHost(), "代理服务器主机地址。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyPort(), "代理服务器端口。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyUsername(), "代理服务器验证的用户名。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyPassword(), "代理服务器验证的密码。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyDomain(), "代理服务器的域,该域可以执行NTLM认证不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyWorkstation(), "代理主机的NTLM身份验证服务器不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSupportCname(), "是否支持CNAME作为Endpoint,默认支持CNAME。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCnameExcludeList(), "设置不可变排除的CName列表 ---- 任何以该列表中的项目结尾的域都不会进行Cname解析。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSldEnabled(), "是否开启二级域名(Second Level Domain)的访问方式,默认不开启。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getRequestTimeout(), "请求超时时间,单位:毫秒。默认情况下是5分钟。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getRequestTimeoutEnabled(), "是否启用请求超时校验。默认情况下,它是禁用的。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSlowRequestsThreshold(), "设置慢请求的延迟阈值。如果请求的延迟大于延迟,则将记录该请求。默认情况下,阈值为5分钟。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getDefaultHeaders(), "设置默认的http头。所有请求头将自动添加到每个请求中。如果在请求中也指定了相同的请求头,则默认的标头将被覆盖。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCrcCheckEnabled(), "是否在上传和下载时启用CRC校验,默认启用不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSignatureVersion(), "所有请求设置签名版本不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getTickOffset(), "设置OSS服务端时间和本地时间之间的差异,以毫秒为单位。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getRedirectEnable(), "是否开启HTTP重定向。 说明: Java SDK 3.10.1及以上版本支持设置是否开启HTTP重定向,默认开启。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getVerifySSLEnable(), "是否开启SSL证书校验。 说明: Java SDK 3.10.1及以上版本支持设置是否开启SSL证书校验,默认开启。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getLogConnectionPoolStats(), "是否开启日志记录连接池统计信息不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUseSystemPropertyValues(), "是否使用系统属性值不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getPartSize(), "分片大小,默认5MB不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getTaskNum(), "并发线程数,默认等于CPU的核数不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getStatus(), "状态不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getOpenAdvancedSetup(), "是否开启高级设置不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCreatedBy(), "创建人不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCreatedTime(), "创建时间不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUpdateTime(), "更新时间不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUpdateBy(), "更新人不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getIsDeleted(), "是否删除 0 未删除 1已删除不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getExtraJson(), "额外字段不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCreateBucket(), "当桶不存在,是否创建不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCheckBucket(), "启动检测桶,是否存在不能为空");
|
||||
SchisandraOssAliBO schisandraOssAliBO = SchisandraOssAliDTOConverter.INSTANCE.convertDTOToBO(schisandraOssAliDTO);
|
||||
return Result.ok(schisandraOssAliDomainService.update(schisandraOssAliBO));
|
||||
} catch (Exception e) {
|
||||
log.error("SchisandraOssAliController.update.error:{}", e.getMessage(), e);
|
||||
return Result.fail("更新信息失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("delete")
|
||||
public Result<Boolean> delete(@RequestBody SchisandraOssAliDTO schisandraOssAliDTO) {
|
||||
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SchisandraOssAliController.delete.dto:{}", JSON.toJSONString(schisandraOssAliDTO));
|
||||
}
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getId(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUserId(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getEndpoint(), "OSS地址不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getAccessKeyId(), "AccessKey ID不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getAccessKeySecret(), "AccessKey Secret不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSecurityToken(), "security Token不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getBucketName(), "Bucket名称不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getBasePath(), "数据存储路径不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUserAgent(), "用户代理,指HTTP的User-Agent头。默认为aliyun-sdk-java。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getMaxErrorRetry(), "请求失败后最大的重试次数。默认3次。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getConnectionRequestTimeout(), "从连接池中获取连接的超时时间(单位:毫秒)。默认不超时。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getConnectionTimeout(), "建立连接的超时时间(单位:毫秒)。默认为50000毫秒。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSocketTimeout(), "Socket层传输数据的超时时间(单位:毫秒)。默认为50000毫秒。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getMaxConnections(), "允许打开的最大HTTP连接数。默认为1024不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getConnectionTTL(), "连接TTL (生存时间)。Http连接由连接管理器用TTL缓存。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUseReaper(), "是否使用com.aliyun.oss.common.comm.IdleConnectionReaper管理过期连接,默认开启不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getIdleConnectionTime(), "连接空闲超时时间,超时则关闭连接(单位:毫秒)。默认为60000毫秒。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProtocol(), "连接OSS所采用的协议(HTTP或HTTPS),默认为HTTP。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyHost(), "代理服务器主机地址。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyPort(), "代理服务器端口。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyUsername(), "代理服务器验证的用户名。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyPassword(), "代理服务器验证的密码。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyDomain(), "代理服务器的域,该域可以执行NTLM认证不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getProxyWorkstation(), "代理主机的NTLM身份验证服务器不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSupportCname(), "是否支持CNAME作为Endpoint,默认支持CNAME。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCnameExcludeList(), "设置不可变排除的CName列表 ---- 任何以该列表中的项目结尾的域都不会进行Cname解析。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSldEnabled(), "是否开启二级域名(Second Level Domain)的访问方式,默认不开启。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getRequestTimeout(), "请求超时时间,单位:毫秒。默认情况下是5分钟。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getRequestTimeoutEnabled(), "是否启用请求超时校验。默认情况下,它是禁用的。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSlowRequestsThreshold(), "设置慢请求的延迟阈值。如果请求的延迟大于延迟,则将记录该请求。默认情况下,阈值为5分钟。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getDefaultHeaders(), "设置默认的http头。所有请求头将自动添加到每个请求中。如果在请求中也指定了相同的请求头,则默认的标头将被覆盖。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCrcCheckEnabled(), "是否在上传和下载时启用CRC校验,默认启用不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getSignatureVersion(), "所有请求设置签名版本不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getTickOffset(), "设置OSS服务端时间和本地时间之间的差异,以毫秒为单位。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getRedirectEnable(), "是否开启HTTP重定向。 说明: Java SDK 3.10.1及以上版本支持设置是否开启HTTP重定向,默认开启。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getVerifySSLEnable(), "是否开启SSL证书校验。 说明: Java SDK 3.10.1及以上版本支持设置是否开启SSL证书校验,默认开启。不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getLogConnectionPoolStats(), "是否开启日志记录连接池统计信息不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUseSystemPropertyValues(), "是否使用系统属性值不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getPartSize(), "分片大小,默认5MB不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getTaskNum(), "并发线程数,默认等于CPU的核数不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getStatus(), "状态不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getOpenAdvancedSetup(), "是否开启高级设置不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCreatedBy(), "创建人不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCreatedTime(), "创建时间不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUpdateTime(), "更新时间不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getUpdateBy(), "更新人不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getIsDeleted(), "是否删除 0 未删除 1已删除不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getExtraJson(), "额外字段不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCreateBucket(), "当桶不存在,是否创建不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssAliDTO.getCheckBucket(), "启动检测桶,是否存在不能为空");
|
||||
SchisandraOssAliBO schisandraOssAliBO = SchisandraOssAliDTOConverter.INSTANCE.convertDTOToBO(schisandraOssAliDTO);
|
||||
return Result.ok(schisandraOssAliDomainService.delete(schisandraOssAliBO));
|
||||
} catch (Exception e) {
|
||||
log.error("SchisandraOssAliController.delete.error:{}", e.getMessage(), e);
|
||||
return Result.fail("删除信息失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,176 +0,0 @@
|
||||
package com.schisandra.oss.application.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.schisandra.oss.application.convert.SchisandraOssConfigDTOConverter;
|
||||
import com.schisandra.oss.application.dto.SchisandraOssConfigDTO;
|
||||
import com.schisandra.oss.common.entity.Result;
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssConfigBO;
|
||||
import com.schisandra.oss.domain.service.SchisandraOssConfigDomainService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* controller
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-11 22:58:14
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/oss/")
|
||||
@Slf4j
|
||||
public class SchisandraOssConfigController {
|
||||
|
||||
@Resource
|
||||
private SchisandraOssConfigDomainService schisandraOssConfigDomainService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@RequestMapping("add")
|
||||
public Result<Boolean> add(@RequestBody SchisandraOssConfigDTO schisandraOssConfigDTO) {
|
||||
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SchisandraOssConfigController.add.dto:{}", JSON.toJSONString(schisandraOssConfigDTO));
|
||||
}
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getId(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getOssType(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getEndpoint(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getAccessKey(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getSecretKey(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getBucketName(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getBasePath(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getRegion(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getTaskNum(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getPartSize(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getImgSize(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getFileSize(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getConnectTimeout(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getWriteTimeout(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getReadTimeout(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getZone(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getPublicKey(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getPrivateKey(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getCustomHost(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getHost(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getPort(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getUser(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getPassword(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getCharset(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getExtraJson(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getCreateDate(), "创建时间不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getUpdateBy(), "更新者不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getUpdateDate(), "更新时间不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getIsDeleted(), "是否删除 0未删除 1已删除不能为空");
|
||||
SchisandraOssConfigBO SchisandraOssConfigBO = SchisandraOssConfigDTOConverter.INSTANCE.convertDTOToBO(schisandraOssConfigDTO);
|
||||
return Result.ok(schisandraOssConfigDomainService.add(SchisandraOssConfigBO));
|
||||
} catch (Exception e) {
|
||||
log.error("SchisandraOssConfigController.register.error:{}", e.getMessage(), e);
|
||||
return Result.fail("新增失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("update")
|
||||
public Result<Boolean> update(@RequestBody SchisandraOssConfigDTO schisandraOssConfigDTO) {
|
||||
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SchisandraOssConfigController.update.dto:{}", JSON.toJSONString(schisandraOssConfigDTO));
|
||||
}
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getId(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getOssType(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getEndpoint(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getAccessKey(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getSecretKey(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getBucketName(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getBasePath(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getRegion(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getTaskNum(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getPartSize(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getImgSize(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getFileSize(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getConnectTimeout(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getWriteTimeout(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getReadTimeout(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getZone(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getPublicKey(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getPrivateKey(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getCustomHost(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getHost(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getPort(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getUser(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getPassword(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getCharset(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getExtraJson(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getCreateDate(), "创建时间不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getUpdateBy(), "更新者不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getUpdateDate(), "更新时间不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getIsDeleted(), "是否删除 0未删除 1已删除不能为空");
|
||||
SchisandraOssConfigBO schisandraOssConfigBO = SchisandraOssConfigDTOConverter.INSTANCE.convertDTOToBO(schisandraOssConfigDTO);
|
||||
return Result.ok(schisandraOssConfigDomainService.update(schisandraOssConfigBO));
|
||||
} catch (Exception e) {
|
||||
log.error("SchisandraOssConfigController.update.error:{}", e.getMessage(), e);
|
||||
return Result.fail("更新信息失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("delete")
|
||||
public Result<Boolean> delete(@RequestBody SchisandraOssConfigDTO schisandraOssConfigDTO) {
|
||||
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SchisandraOssConfigController.delete.dto:{}", JSON.toJSONString(schisandraOssConfigDTO));
|
||||
}
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getId(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getOssType(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getEndpoint(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getAccessKey(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getSecretKey(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getBucketName(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getBasePath(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getRegion(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getTaskNum(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getPartSize(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getImgSize(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getFileSize(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getConnectTimeout(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getWriteTimeout(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getReadTimeout(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getZone(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getPublicKey(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getPrivateKey(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getCustomHost(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getHost(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getPort(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getUser(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getPassword(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getCharset(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getExtraJson(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getCreateDate(), "创建时间不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getUpdateBy(), "更新者不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getUpdateDate(), "更新时间不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssConfigDTO.getIsDeleted(), "是否删除 0未删除 1已删除不能为空");
|
||||
SchisandraOssConfigBO schisandraOssConfigBO = SchisandraOssConfigDTOConverter.INSTANCE.convertDTOToBO(schisandraOssConfigDTO);
|
||||
return Result.ok(schisandraOssConfigDomainService.delete(schisandraOssConfigBO));
|
||||
} catch (Exception e) {
|
||||
log.error("SchisandraOssConfigController.delete.error:{}", e.getMessage(), e);
|
||||
return Result.fail("删除信息失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,198 @@
|
||||
package com.schisandra.oss.application.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.schisandra.oss.application.convert.SchisandraOssMinioDTOConverter;
|
||||
import com.schisandra.oss.application.dto.SchisandraOssMinioDTO;
|
||||
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
||||
import com.schisandra.oss.application.oss.core.minio.MinioOssClient;
|
||||
import com.schisandra.oss.application.oss.core.minio.model.MinioOssClientConfig;
|
||||
import com.schisandra.oss.application.oss.core.minio.model.MinioOssConfig;
|
||||
import com.schisandra.oss.common.entity.Result;
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssMinioBO;
|
||||
import com.schisandra.oss.domain.service.SchisandraOssMinioDomainService;
|
||||
import io.minio.MinioClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* controller
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 19:47:04
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/oss/")
|
||||
@Slf4j
|
||||
public class SchisandraOssMinioController {
|
||||
|
||||
@Resource
|
||||
private SchisandraOssMinioDomainService schisandraOssMinioDomainService;
|
||||
|
||||
// @Resource
|
||||
// private MinioOssClient minioOssClient;
|
||||
|
||||
@PostMapping("initMinio")
|
||||
public StandardOssClient initMinio() {
|
||||
SchisandraOssMinioBO minioBO = schisandraOssMinioDomainService.getMinioConfig(1L);
|
||||
SchisandraOssMinioDTO minio = SchisandraOssMinioDTOConverter.INSTANCE.convertBOToDTO(minioBO);
|
||||
if (ObjectUtils.isEmpty(minio)) {
|
||||
log.error("minio配置信息获取失败");
|
||||
}
|
||||
MinioOssConfig minioOssConfig = new MinioOssConfig();
|
||||
minioOssConfig.setBasePath(minio.getBasePath());
|
||||
minioOssConfig.setBucketName(minio.getBucketName());
|
||||
minioOssConfig.setAccessKey(minio.getAccessKey());
|
||||
minioOssConfig.setSecretKey(minio.getSecretKey());
|
||||
minioOssConfig.setEndpoint(minio.getEndpoint());
|
||||
minioOssConfig.init();
|
||||
if (Boolean.parseBoolean(minio.getOpenAdvancedSetup())) {
|
||||
MinioOssClientConfig minioOssClientConfig = new MinioOssClientConfig();
|
||||
minioOssClientConfig.setWriteTimeout(minio.getWriteTimeout());
|
||||
minioOssClientConfig.setConnectTimeout(minio.getConnectTimeout());
|
||||
minioOssClientConfig.setReadTimeout(minio.getReadTimeout());
|
||||
minioOssClientConfig.setFollowSslRedirects(Boolean.parseBoolean(minio.getFollowSslRedirects()));
|
||||
minioOssClientConfig.setRetryOnConnectionFailure(Boolean.parseBoolean(minio.getRetryOnConnectionFailure()));
|
||||
minioOssClientConfig.setPingInterval(minio.getPingInterval());
|
||||
minioOssClientConfig.setFollowRedirects(Boolean.parseBoolean(minio.getFollowRedirects()));
|
||||
minioOssClientConfig.setCallTimeout(minio.getCallTimeout());
|
||||
minioOssConfig.setClientConfig(minioOssClientConfig);
|
||||
}
|
||||
return minioOssClient(minioOssConfig);
|
||||
|
||||
}
|
||||
|
||||
public StandardOssClient minioOssClient(MinioOssConfig minioOssConfig) {
|
||||
return new MinioOssClient(minioClient(minioOssConfig), minioOssConfig);
|
||||
}
|
||||
|
||||
public MinioClient minioClient(MinioOssConfig minioOssConfig) {
|
||||
MinioOssClientConfig clientConfig = minioOssConfig.getClientConfig();
|
||||
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
||||
.connectTimeout(clientConfig.getConnectTimeout(), TimeUnit.MILLISECONDS)
|
||||
.writeTimeout(clientConfig.getWriteTimeout(), TimeUnit.MILLISECONDS)
|
||||
.readTimeout(clientConfig.getReadTimeout(), TimeUnit.MILLISECONDS)
|
||||
.callTimeout(clientConfig.getCallTimeout(), TimeUnit.MILLISECONDS)
|
||||
.followRedirects(clientConfig.isFollowRedirects())
|
||||
.followSslRedirects(clientConfig.isFollowSslRedirects())
|
||||
.retryOnConnectionFailure(clientConfig.isRetryOnConnectionFailure())
|
||||
.pingInterval(clientConfig.getPingInterval(), TimeUnit.MILLISECONDS)
|
||||
.build();
|
||||
return MinioClient.builder()
|
||||
.endpoint(minioOssConfig.getEndpoint())
|
||||
.credentials(minioOssConfig.getAccessKey(), minioOssConfig.getSecretKey())
|
||||
.httpClient(okHttpClient)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@RequestMapping("addMinio")
|
||||
public Result<Boolean> addMinioOss(@RequestBody SchisandraOssMinioDTO schisandraOssMinioDTO) {
|
||||
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SchisandraOssMinioController.add.dto:{}", JSON.toJSONString(schisandraOssMinioDTO));
|
||||
}
|
||||
parameterCheck(schisandraOssMinioDTO);
|
||||
SchisandraOssMinioBO SchisandraOssMinioBO = SchisandraOssMinioDTOConverter.INSTANCE.convertDTOToBO(schisandraOssMinioDTO);
|
||||
return Result.ok(schisandraOssMinioDomainService.add(SchisandraOssMinioBO));
|
||||
} catch (Exception e) {
|
||||
log.error("SchisandraOssMinioController.register.error:{}", e.getMessage(), e);
|
||||
return Result.fail("新增失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("updateMinio")
|
||||
public Result<Boolean> updateMinioOss(@RequestBody SchisandraOssMinioDTO schisandraOssMinioDTO) {
|
||||
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SchisandraOssMinioController.update.dto:{}", JSON.toJSONString(schisandraOssMinioDTO));
|
||||
}
|
||||
parameterCheck(schisandraOssMinioDTO);
|
||||
SchisandraOssMinioBO schisandraOssMinioBO = SchisandraOssMinioDTOConverter.INSTANCE.convertDTOToBO(schisandraOssMinioDTO);
|
||||
return Result.ok(schisandraOssMinioDomainService.update(schisandraOssMinioBO));
|
||||
} catch (Exception e) {
|
||||
log.error("SchisandraOssMinioController.update.error:{}", e.getMessage(), e);
|
||||
return Result.fail("更新信息失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("deleteMinio")
|
||||
public Result<Boolean> deleteMinioOss(@RequestBody SchisandraOssMinioDTO schisandraOssMinioDTO) {
|
||||
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SchisandraOssMinioController.delete.dto:{}", JSON.toJSONString(schisandraOssMinioDTO));
|
||||
}
|
||||
parameterCheck(schisandraOssMinioDTO);
|
||||
SchisandraOssMinioBO schisandraOssMinioBO = SchisandraOssMinioDTOConverter.INSTANCE.convertDTOToBO(schisandraOssMinioDTO);
|
||||
return Result.ok(schisandraOssMinioDomainService.delete(schisandraOssMinioBO));
|
||||
} catch (Exception e) {
|
||||
log.error("SchisandraOssMinioController.delete.error:{}", e.getMessage(), e);
|
||||
return Result.fail("删除信息失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping("testMinio")
|
||||
public void test() {
|
||||
// System.out.println(minioOssClient.getBasePath());
|
||||
}
|
||||
|
||||
|
||||
private void parameterCheck(SchisandraOssMinioDTO schisandraOssMinioDTO) {
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getId(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getUserId(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getEndpoint(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getAccessKey(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getSecretKey(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getBucketName(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getPort(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getBasePath(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getFileHost(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getDownloadHost(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getUploadHost(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getCreateBucket(), "当桶不存在,是否创建不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getCheckBucket(), "启动检测桶,是否存在不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getConnectTimeout(), "连接超时时间(单位:毫秒)不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getWriteTimeout(), "写超时时间(单位:毫秒)不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getReadTimeout(), "读超时时间(单位:毫秒)不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getCallTimeout(), "调用超时时间(单位:毫秒)不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getFollowRedirects(), "是否支持重定向,默认支持不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getFollowSslRedirects(), "是否支持HTTP到HTTPS,HTTPS到HTTP的重定向,默认支持不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getRetryOnConnectionFailure(), "是否开始连接失败重试,默认不支持不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getPingInterval(), "连接健康检测间隔时长(单位:毫秒)不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getPartSize(), "分片大小,默认5MB不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getTaskNum(), "并发线程数,默认等于CPU的核数不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getImgSize(), "图片大小限制,单位:m不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getFileSize(), "文件大小限制,单位:m不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getExtraJson(), "额外json不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getStatus(), "状态不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getCreatedBy(), "创建人不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getCreatedTime(), "创建时间不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getUpdateTime(), "更新时间不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getUpdateBy(), "更新人不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getIsDeleted(), "是否删除 0 未删除 1已删除不能为空");
|
||||
Preconditions.checkNotNull(schisandraOssMinioDTO.getOpenAdvancedSetup(), "是否开启高级设置不能为空");
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.schisandra.oss.application.convert;
|
||||
|
||||
|
||||
import com.schisandra.oss.application.dto.SchisandraOssAliDTO;
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* dto转换器
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 20:45:32
|
||||
*/
|
||||
@Mapper
|
||||
public interface SchisandraOssAliDTOConverter {
|
||||
|
||||
SchisandraOssAliDTOConverter INSTANCE = Mappers.getMapper(SchisandraOssAliDTOConverter.class);
|
||||
|
||||
SchisandraOssAliBO convertDTOToBO(SchisandraOssAliDTO schisandraOssAliDTO);
|
||||
SchisandraOssAliDTO convertBOToDTO(SchisandraOssAliBO schisandraOssAli);
|
||||
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
package com.schisandra.oss.application.convert;
|
||||
|
||||
|
||||
import com.schisandra.oss.application.dto.SchisandraOssConfigDTO;
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssConfigBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* dto转换器
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-11 22:58:14
|
||||
*/
|
||||
@Mapper
|
||||
public interface SchisandraOssConfigDTOConverter {
|
||||
|
||||
SchisandraOssConfigDTOConverter INSTANCE = Mappers.getMapper(SchisandraOssConfigDTOConverter.class);
|
||||
|
||||
SchisandraOssConfigBO convertDTOToBO(SchisandraOssConfigDTO schisandraOssConfigDTO);
|
||||
SchisandraOssConfigDTO convertBOToDTO(SchisandraOssConfigBO schisandraOssConfig);
|
||||
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.schisandra.oss.application.convert;
|
||||
|
||||
|
||||
import com.schisandra.oss.application.dto.SchisandraOssMinioDTO;
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssMinioBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* dto转换器
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 19:47:04
|
||||
*/
|
||||
@Mapper
|
||||
public interface SchisandraOssMinioDTOConverter {
|
||||
|
||||
SchisandraOssMinioDTOConverter INSTANCE = Mappers.getMapper(SchisandraOssMinioDTOConverter.class);
|
||||
|
||||
SchisandraOssMinioBO convertDTOToBO(SchisandraOssMinioDTO schisandraOssMinioDTO);
|
||||
|
||||
SchisandraOssMinioDTO convertBOToDTO(SchisandraOssMinioBO schisandraOssMinioBO);
|
||||
}
|
@@ -0,0 +1,270 @@
|
||||
package com.schisandra.oss.application.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* dto
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 20:45:32
|
||||
*/
|
||||
@Data
|
||||
public class SchisandraOssAliDTO implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* OSS地址
|
||||
*/
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
* AccessKey ID
|
||||
*/
|
||||
private String accessKeyId;
|
||||
|
||||
/**
|
||||
* AccessKey Secret
|
||||
*/
|
||||
private String accessKeySecret;
|
||||
|
||||
/**
|
||||
* security Token
|
||||
*/
|
||||
private String securityToken;
|
||||
|
||||
/**
|
||||
* Bucket名称
|
||||
*/
|
||||
private String bucketName;
|
||||
|
||||
/**
|
||||
* 数据存储路径
|
||||
*/
|
||||
private String basePath;
|
||||
|
||||
/**
|
||||
* 用户代理,指HTTP的User-Agent头。默认为aliyun-sdk-java。
|
||||
*/
|
||||
private String userAgent;
|
||||
|
||||
/**
|
||||
* 请求失败后最大的重试次数。默认3次。
|
||||
*/
|
||||
private String maxErrorRetry;
|
||||
|
||||
/**
|
||||
* 从连接池中获取连接的超时时间(单位:毫秒)。默认不超时。
|
||||
*/
|
||||
private Integer connectionRequestTimeout;
|
||||
|
||||
/**
|
||||
* 建立连接的超时时间(单位:毫秒)。默认为50000毫秒。
|
||||
*/
|
||||
private Integer connectionTimeout;
|
||||
|
||||
/**
|
||||
* Socket层传输数据的超时时间(单位:毫秒)。默认为50000毫秒。
|
||||
*/
|
||||
private Integer socketTimeout;
|
||||
|
||||
/**
|
||||
* 允许打开的最大HTTP连接数。默认为1024
|
||||
*/
|
||||
private Integer maxConnections;
|
||||
|
||||
/**
|
||||
* 连接TTL (生存时间)。Http连接由连接管理器用TTL缓存。
|
||||
*/
|
||||
private Long connectionTTL;
|
||||
|
||||
/**
|
||||
* 是否使用com.aliyun.oss.common.comm.IdleConnectionReaper管理过期连接,默认开启
|
||||
*/
|
||||
private String useReaper;
|
||||
|
||||
/**
|
||||
* 连接空闲超时时间,超时则关闭连接(单位:毫秒)。默认为60000毫秒。
|
||||
*/
|
||||
private Long idleConnectionTime;
|
||||
|
||||
/**
|
||||
* 连接OSS所采用的协议(HTTP或HTTPS),默认为HTTP。
|
||||
*/
|
||||
private String protocol;
|
||||
|
||||
/**
|
||||
* 代理服务器主机地址。
|
||||
*/
|
||||
private String proxyHost;
|
||||
|
||||
/**
|
||||
* 代理服务器端口。
|
||||
*/
|
||||
private String proxyPort;
|
||||
|
||||
/**
|
||||
* 代理服务器验证的用户名。
|
||||
*/
|
||||
private String proxyUsername;
|
||||
|
||||
/**
|
||||
* 代理服务器验证的密码。
|
||||
*/
|
||||
private String proxyPassword;
|
||||
|
||||
/**
|
||||
* 代理服务器的域,该域可以执行NTLM认证
|
||||
*/
|
||||
private String proxyDomain;
|
||||
|
||||
/**
|
||||
* 代理主机的NTLM身份验证服务器
|
||||
*/
|
||||
private String proxyWorkstation;
|
||||
|
||||
/**
|
||||
* 是否支持CNAME作为Endpoint,默认支持CNAME。
|
||||
*/
|
||||
private String supportCname;
|
||||
|
||||
/**
|
||||
* 设置不可变排除的CName列表 ---- 任何以该列表中的项目结尾的域都不会进行Cname解析。
|
||||
*/
|
||||
private String cnameExcludeList;
|
||||
|
||||
/**
|
||||
* 是否开启二级域名(Second Level Domain)的访问方式,默认不开启。
|
||||
*/
|
||||
private String sldEnabled;
|
||||
|
||||
/**
|
||||
* 请求超时时间,单位:毫秒。默认情况下是5分钟。
|
||||
*/
|
||||
private Integer requestTimeout;
|
||||
|
||||
/**
|
||||
* 是否启用请求超时校验。默认情况下,它是禁用的。
|
||||
*/
|
||||
private String requestTimeoutEnabled;
|
||||
|
||||
/**
|
||||
* 设置慢请求的延迟阈值。如果请求的延迟大于延迟,则将记录该请求。默认情况下,阈值为5分钟。
|
||||
*/
|
||||
private Long slowRequestsThreshold;
|
||||
|
||||
/**
|
||||
* 设置默认的http头。所有请求头将自动添加到每个请求中。如果在请求中也指定了相同的请求头,则默认的标头将被覆盖。
|
||||
*/
|
||||
private String defaultHeaders;
|
||||
|
||||
/**
|
||||
* 是否在上传和下载时启用CRC校验,默认启用
|
||||
*/
|
||||
private String crcCheckEnabled;
|
||||
|
||||
/**
|
||||
* 所有请求设置签名版本
|
||||
*/
|
||||
private String signatureVersion;
|
||||
|
||||
/**
|
||||
* 设置OSS服务端时间和本地时间之间的差异,以毫秒为单位。
|
||||
*/
|
||||
private Long tickOffset;
|
||||
|
||||
/**
|
||||
* 是否开启HTTP重定向。
|
||||
说明: Java SDK 3.10.1及以上版本支持设置是否开启HTTP重定向,默认开启。
|
||||
*/
|
||||
private String redirectEnable;
|
||||
|
||||
/**
|
||||
* 是否开启SSL证书校验。
|
||||
* 说明: Java SDK 3.10.1及以上版本支持设置是否开启SSL证书校验,默认开启。
|
||||
*/
|
||||
private String verifySSLEnable;
|
||||
|
||||
/**
|
||||
* 是否开启日志记录连接池统计信息
|
||||
*/
|
||||
private String logConnectionPoolStats;
|
||||
|
||||
/**
|
||||
* 是否使用系统属性值
|
||||
*/
|
||||
private String useSystemPropertyValues;
|
||||
|
||||
/**
|
||||
* 分片大小,默认5MB
|
||||
*/
|
||||
private Integer partSize;
|
||||
|
||||
/**
|
||||
* 并发线程数,默认等于CPU的核数
|
||||
*/
|
||||
private Integer taskNum;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 是否开启高级设置
|
||||
*/
|
||||
private String openAdvancedSetup;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 是否删除 0 未删除 1已删除
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 额外字段
|
||||
*/
|
||||
private String extraJson;
|
||||
|
||||
/**
|
||||
* 当桶不存在,是否创建
|
||||
*/
|
||||
private String createBucket;
|
||||
|
||||
/**
|
||||
* 启动检测桶,是否存在
|
||||
*/
|
||||
private String checkBucket;
|
||||
|
||||
}
|
||||
|
@@ -1,163 +0,0 @@
|
||||
package com.schisandra.oss.application.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* dto
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-11 22:58:14
|
||||
*/
|
||||
@Data
|
||||
public class SchisandraOssConfigDTO implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String ossType;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String accessKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String bucketName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String basePath;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String region;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer taskNum;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String partSize;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Double imgSize;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Double fileSize;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer connectTimeout;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer writeTimeout;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer readTimeout;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String zone;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String publicKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String privateKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String customHost;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String port;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String user;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String charset;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String extraJson;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createDate;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateDate;
|
||||
|
||||
/**
|
||||
* 是否删除 0未删除 1已删除
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,183 @@
|
||||
package com.schisandra.oss.application.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* dto
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 19:47:04
|
||||
*/
|
||||
@Data
|
||||
public class SchisandraOssMinioDTO implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String accessKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String bucketName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer port;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String basePath;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String fileHost;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String downloadHost;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String uploadHost;
|
||||
|
||||
/**
|
||||
* 当桶不存在,是否创建
|
||||
*/
|
||||
private String createBucket;
|
||||
|
||||
/**
|
||||
* 启动检测桶,是否存在
|
||||
*/
|
||||
private String checkBucket;
|
||||
|
||||
/**
|
||||
* 连接超时时间(单位:毫秒)
|
||||
*/
|
||||
private Long connectTimeout;
|
||||
|
||||
/**
|
||||
* 写超时时间(单位:毫秒)
|
||||
*/
|
||||
private Long writeTimeout;
|
||||
|
||||
/**
|
||||
* 读超时时间(单位:毫秒)
|
||||
*/
|
||||
private Long readTimeout;
|
||||
|
||||
/**
|
||||
* 调用超时时间(单位:毫秒)
|
||||
*/
|
||||
private Long callTimeout;
|
||||
|
||||
/**
|
||||
* 是否支持重定向,默认支持
|
||||
*/
|
||||
private String followRedirects;
|
||||
|
||||
/**
|
||||
* 是否支持HTTP到HTTPS,HTTPS到HTTP的重定向,默认支持
|
||||
*/
|
||||
private String followSslRedirects;
|
||||
|
||||
/**
|
||||
* 是否开始连接失败重试,默认不支持
|
||||
*/
|
||||
private String retryOnConnectionFailure;
|
||||
|
||||
/**
|
||||
* 连接健康检测间隔时长(单位:毫秒)
|
||||
*/
|
||||
private Integer pingInterval;
|
||||
|
||||
/**
|
||||
* 分片大小,默认5MB
|
||||
*/
|
||||
private Long partSize;
|
||||
|
||||
/**
|
||||
* 并发线程数,默认等于CPU的核数
|
||||
*/
|
||||
private Integer taskNum;
|
||||
|
||||
/**
|
||||
* 图片大小限制,单位:m
|
||||
*/
|
||||
private Integer imgSize;
|
||||
|
||||
/**
|
||||
* 文件大小限制,单位:m
|
||||
*/
|
||||
private Integer fileSize;
|
||||
|
||||
/**
|
||||
* 额外json
|
||||
*/
|
||||
private String extraJson;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 是否删除 0 未删除 1已删除
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 是否开启高级设置
|
||||
*/
|
||||
private String openAdvancedSetup;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,661 @@
|
||||
package com.schisandra.oss.application.oss.core;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.io.file.FileNameUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||
import com.schisandra.oss.application.oss.exception.OssException;
|
||||
import com.schisandra.oss.application.oss.model.OssInfo;
|
||||
import com.schisandra.oss.application.oss.model.SliceConfig;
|
||||
import com.schisandra.oss.application.oss.model.download.DownloadCheckPoint;
|
||||
import com.schisandra.oss.application.oss.model.download.DownloadObjectStat;
|
||||
import com.schisandra.oss.application.oss.model.download.DownloadPart;
|
||||
import com.schisandra.oss.application.oss.model.download.DownloadPartResult;
|
||||
import com.schisandra.oss.application.oss.model.upload.UpLoadCheckPoint;
|
||||
import com.schisandra.oss.application.oss.model.upload.UpLoadPartEntityTag;
|
||||
import com.schisandra.oss.application.oss.model.upload.UpLoadPartResult;
|
||||
import com.schisandra.oss.application.oss.model.upload.UploadPart;
|
||||
import com.schisandra.oss.application.oss.utils.OssPathUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
||||
* @version AbstractOssClient.java, v 1.1 2021/11/5 15:44 chenmin Exp $
|
||||
* Created on 2021/11/5
|
||||
*/
|
||||
|
||||
public interface StandardOssClient {
|
||||
|
||||
/**
|
||||
* 上传文件,默认覆盖
|
||||
* @param is 输入流
|
||||
* @param targetName 目标文件路径
|
||||
* @return 文件信息
|
||||
*/
|
||||
default OssInfo upLoad(InputStream is, String targetName) {
|
||||
return upLoad(is, targetName, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* @param is 输入流
|
||||
* @param targetName 目标文件路径
|
||||
* @param isOverride 是否覆盖
|
||||
* @return 文件信息
|
||||
*/
|
||||
OssInfo upLoad(InputStream is, String targetName, Boolean isOverride);
|
||||
|
||||
/**
|
||||
* 断点续传
|
||||
* @param file 本地文件路径
|
||||
* @param targetName 目标文件路径
|
||||
* @return 文件信息
|
||||
*/
|
||||
default OssInfo upLoadCheckPoint(String file, String targetName) {
|
||||
return upLoadCheckPoint(new File(file), targetName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 断点续传
|
||||
* @param file 本地文件
|
||||
* @param targetName 目标文件路径
|
||||
* @return 文件信息
|
||||
*/
|
||||
OssInfo upLoadCheckPoint(File file, String targetName);
|
||||
|
||||
/**
|
||||
* 断点续传上传
|
||||
* @param upLoadFile 上传文件
|
||||
* @param targetName 目标对象路径
|
||||
* @param slice 分片参数
|
||||
* @param ossType OSS类型
|
||||
* @return 上传文件信息
|
||||
*/
|
||||
default OssInfo uploadFile(File upLoadFile, String targetName, SliceConfig slice, String ossType) {
|
||||
String checkpointFile = upLoadFile.getPath() + StrUtil.DOT + ossType;
|
||||
|
||||
UpLoadCheckPoint upLoadCheckPoint = new UpLoadCheckPoint();
|
||||
try {
|
||||
upLoadCheckPoint.load(checkpointFile);
|
||||
} catch (Exception e) {
|
||||
FileUtil.del(checkpointFile);
|
||||
}
|
||||
|
||||
if (!upLoadCheckPoint.isValid()) {
|
||||
prepareUpload(upLoadCheckPoint, upLoadFile, targetName, checkpointFile, slice);
|
||||
FileUtil.del(checkpointFile);
|
||||
}
|
||||
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(slice.getTaskNum());
|
||||
List<Future<UpLoadPartResult>> futures = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < upLoadCheckPoint.getUploadParts().size(); i++) {
|
||||
if (!upLoadCheckPoint.getUploadParts().get(i).isCompleted()) {
|
||||
futures.add(executorService.submit(new UploadPartTask(this, upLoadCheckPoint, i)));
|
||||
}
|
||||
}
|
||||
|
||||
executorService.shutdown();
|
||||
|
||||
for (Future<UpLoadPartResult> future : futures) {
|
||||
try {
|
||||
UpLoadPartResult partResult = future.get();
|
||||
if (partResult.isFailed()) {
|
||||
throw partResult.getException();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new OssException(e);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (!executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS)) {
|
||||
executorService.shutdownNow();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new OssException("关闭线程池失败", e);
|
||||
}
|
||||
|
||||
List<UpLoadPartEntityTag> partEntityTags = upLoadCheckPoint.getPartEntityTags();
|
||||
completeUpload(upLoadCheckPoint, partEntityTags);
|
||||
|
||||
return getInfo(targetName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成分片上传
|
||||
* @param upLoadCheckPoint 断点对象
|
||||
* @param partEntityTags 所有分片
|
||||
*/
|
||||
default void completeUpload(UpLoadCheckPoint upLoadCheckPoint, List<UpLoadPartEntityTag> partEntityTags) {
|
||||
FileUtil.del(upLoadCheckPoint.getCheckpointFile());
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化断点续传对象
|
||||
* @param uploadCheckPoint 断点续传对象
|
||||
* @param upLoadFile 要上传的文件
|
||||
* @param targetName 上传文件名
|
||||
* @param checkpointFile 断点文件
|
||||
* @param slice 分片参数
|
||||
*/
|
||||
default void prepareUpload(UpLoadCheckPoint uploadCheckPoint, File upLoadFile, String targetName, String checkpointFile, SliceConfig slice) {
|
||||
throw new OssException("初始化断点续传对象未实现,默认不支持此方法");
|
||||
}
|
||||
|
||||
/**
|
||||
* 拆分上传分片
|
||||
* @param fileSize 文件大小
|
||||
* @param partSize 分片大小
|
||||
* @return 所有分片对象
|
||||
*/
|
||||
default ArrayList<UploadPart> splitUploadFile(long fileSize, long partSize) {
|
||||
ArrayList<UploadPart> parts = new ArrayList<>();
|
||||
|
||||
long partNum = fileSize / partSize;
|
||||
if (partNum >= OssConstant.DEFAULT_PART_NUM) {
|
||||
partSize = fileSize / (OssConstant.DEFAULT_PART_NUM - 1);
|
||||
partNum = fileSize / partSize;
|
||||
}
|
||||
|
||||
for (long i = 0; i < partNum; i++) {
|
||||
UploadPart part = new UploadPart();
|
||||
part.setNumber((int) (i + 1));
|
||||
part.setOffset(i * partSize);
|
||||
part.setSize(partSize);
|
||||
part.setCompleted(false);
|
||||
parts.add(part);
|
||||
}
|
||||
|
||||
if (fileSize % partSize > 0) {
|
||||
UploadPart part = new UploadPart();
|
||||
part.setNumber(parts.size() + 1);
|
||||
part.setOffset(parts.size() * partSize);
|
||||
part.setSize(fileSize % partSize);
|
||||
part.setCompleted(false);
|
||||
parts.add(part);
|
||||
}
|
||||
|
||||
return parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分片上传Task
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
class UploadPartTask implements Callable<UpLoadPartResult> {
|
||||
/**
|
||||
* OSS客户端
|
||||
*/
|
||||
private StandardOssClient ossClient;
|
||||
/**
|
||||
* 断点续传对象
|
||||
*/
|
||||
private UpLoadCheckPoint upLoadCheckPoint;
|
||||
/**
|
||||
* 分片索引
|
||||
*/
|
||||
private int partNum;
|
||||
|
||||
@Override
|
||||
public UpLoadPartResult call() {
|
||||
InputStream inputStream = FileUtil.getInputStream(upLoadCheckPoint.getUploadFile());
|
||||
UpLoadPartResult upLoadPartResult = ossClient.uploadPart(upLoadCheckPoint, partNum, inputStream);
|
||||
if (!upLoadPartResult.isFailed()) {
|
||||
upLoadCheckPoint.update(partNum, upLoadPartResult.getEntityTag(), true);
|
||||
upLoadCheckPoint.dump();
|
||||
}
|
||||
return upLoadPartResult;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传分片
|
||||
* @param upLoadCheckPoint 断点续传对象
|
||||
* @param partNum 分片索引
|
||||
* @param inputStream 文件流
|
||||
* @return 上传结果
|
||||
*/
|
||||
default UpLoadPartResult uploadPart(UpLoadCheckPoint upLoadCheckPoint, int partNum, InputStream inputStream) {
|
||||
throw new OssException("上传文件分片方法未实现,默认不支持此方法");
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
* @param os 输出流
|
||||
* @param targetName 目标文件路径
|
||||
*/
|
||||
void downLoad(OutputStream os, String targetName);
|
||||
|
||||
/**
|
||||
* 断点续传
|
||||
* @param localFile 本地文件路径
|
||||
* @param targetName 目标文件路径
|
||||
*/
|
||||
default void downLoadCheckPoint(String localFile, String targetName) {
|
||||
downLoadCheckPoint(new File(localFile), targetName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 断点续传
|
||||
* @param localFile 本地文件
|
||||
* @param targetName 目标文件路径
|
||||
*/
|
||||
void downLoadCheckPoint(File localFile, String targetName);
|
||||
|
||||
/**
|
||||
* 断点续传下载
|
||||
* @param localFile 本地文件
|
||||
* @param targetName 目标对象
|
||||
* @param slice 分片参数
|
||||
* @param ossType OSS类型
|
||||
*/
|
||||
default void downLoadFile(File localFile, String targetName, SliceConfig slice, String ossType) {
|
||||
|
||||
String checkpointFile = localFile.getPath() + StrUtil.DOT + ossType;
|
||||
|
||||
DownloadCheckPoint downloadCheckPoint = new DownloadCheckPoint();
|
||||
try {
|
||||
downloadCheckPoint.load(checkpointFile);
|
||||
} catch (Exception e) {
|
||||
FileUtil.del(checkpointFile);
|
||||
}
|
||||
|
||||
DownloadObjectStat downloadObjectStat = getDownloadObjectStat(targetName);
|
||||
if (!downloadCheckPoint.isValid(downloadObjectStat)) {
|
||||
prepareDownload(downloadCheckPoint, localFile, targetName, checkpointFile);
|
||||
FileUtil.del(checkpointFile);
|
||||
}
|
||||
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(slice.getTaskNum());
|
||||
List<Future<DownloadPartResult>> futures = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < downloadCheckPoint.getDownloadParts().size(); i++) {
|
||||
if (!downloadCheckPoint.getDownloadParts().get(i).isCompleted()) {
|
||||
futures.add(executorService.submit(new DownloadPartTask(this, downloadCheckPoint, i)));
|
||||
}
|
||||
}
|
||||
|
||||
executorService.shutdown();
|
||||
|
||||
for (Future<DownloadPartResult> future : futures) {
|
||||
try {
|
||||
DownloadPartResult partResult = future.get();
|
||||
if (partResult.isFailed()) {
|
||||
throw partResult.getException();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new OssException(e);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (!executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS)) {
|
||||
executorService.shutdownNow();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new OssException("关闭线程池失败", e);
|
||||
}
|
||||
|
||||
FileUtil.rename(new File(downloadCheckPoint.getTempDownloadFile()), downloadCheckPoint.getDownloadFile(), true);
|
||||
FileUtil.del(downloadCheckPoint.getCheckPointFile());
|
||||
}
|
||||
|
||||
/**
|
||||
* 分片下载Task
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class DownloadPartTask implements Callable<DownloadPartResult> {
|
||||
|
||||
/**
|
||||
* Oss客户端
|
||||
*/
|
||||
StandardOssClient ossClient;
|
||||
/**
|
||||
* 断点续传对象
|
||||
*/
|
||||
DownloadCheckPoint downloadCheckPoint;
|
||||
/**
|
||||
* 分片索引
|
||||
*/
|
||||
int partNum;
|
||||
|
||||
@Override
|
||||
public DownloadPartResult call() {
|
||||
DownloadPartResult partResult = null;
|
||||
RandomAccessFile output = null;
|
||||
InputStream content = null;
|
||||
try {
|
||||
DownloadPart downloadPart = downloadCheckPoint.getDownloadParts().get(partNum);
|
||||
|
||||
partResult = new DownloadPartResult(partNum + 1, downloadPart.getStart(), downloadPart.getEnd());
|
||||
|
||||
output = new RandomAccessFile(downloadCheckPoint.getTempDownloadFile(), "rw");
|
||||
output.seek(downloadPart.getFileStart());
|
||||
|
||||
content = ossClient.downloadPart(downloadCheckPoint.getKey(), downloadPart.getStart(), downloadPart.getEnd());
|
||||
|
||||
long partSize = downloadPart.getEnd() - downloadPart.getStart();
|
||||
byte[] buffer = new byte[Convert.toInt(partSize)];
|
||||
int bytesRead = 0;
|
||||
while ((bytesRead = content.read(buffer)) != -1) {
|
||||
output.write(buffer, 0, bytesRead);
|
||||
}
|
||||
|
||||
partResult.setLength(downloadPart.getLength());
|
||||
downloadCheckPoint.update(partNum, true);
|
||||
downloadCheckPoint.dump();
|
||||
} catch (Exception e) {
|
||||
partResult.setException(e);
|
||||
partResult.setFailed(true);
|
||||
} finally {
|
||||
IoUtil.close(output);
|
||||
IoUtil.close(content);
|
||||
}
|
||||
return partResult;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取目标文件状态
|
||||
* @param targetName 目标对象路径
|
||||
* @return 目标文件状态
|
||||
*/
|
||||
default DownloadObjectStat getDownloadObjectStat(String targetName) {
|
||||
throw new OssException("获取下载对象状态方法未实现,默认不支持此方法");
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化断点续传下载对象
|
||||
* @param downloadCheckPoint 断点对象
|
||||
* @param localFile 本地文件
|
||||
* @param targetName 目标对象路径
|
||||
* @param checkpointFile 下载进度缓存文件
|
||||
*/
|
||||
default void prepareDownload(DownloadCheckPoint downloadCheckPoint, File localFile, String targetName, String checkpointFile) {
|
||||
throw new OssException("初始化断点续传下载对象方法未实现,默认不支持此方法");
|
||||
}
|
||||
|
||||
/**
|
||||
* 拆分文件分片
|
||||
* @param start 开始字节数
|
||||
* @param objectSize 对象大小
|
||||
* @param partSize 预设分片大小
|
||||
* @return 所有分片对象
|
||||
*/
|
||||
default ArrayList<DownloadPart> splitDownloadFile(long start, long objectSize, long partSize) {
|
||||
ArrayList<DownloadPart> parts = new ArrayList<>();
|
||||
|
||||
long partNum = objectSize / partSize;
|
||||
if (partNum >= OssConstant.DEFAULT_PART_NUM) {
|
||||
partSize = objectSize / (OssConstant.DEFAULT_PART_NUM - 1);
|
||||
}
|
||||
|
||||
long offset = 0L;
|
||||
for (int i = 0; offset < objectSize; offset += partSize, i++) {
|
||||
DownloadPart part = new DownloadPart();
|
||||
part.setIndex(i);
|
||||
part.setStart(offset + start);
|
||||
part.setEnd(getPartEnd(offset, objectSize, partSize) + start);
|
||||
part.setFileStart(offset);
|
||||
parts.add(part);
|
||||
}
|
||||
|
||||
return parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分片结束字节数
|
||||
* @param begin 开始字节数
|
||||
* @param total 目标对象大小
|
||||
* @param per 预设分片大小
|
||||
* @return 分片结束字节数
|
||||
*/
|
||||
default long getPartEnd(long begin, long total, long per) {
|
||||
if (begin + per > total) {
|
||||
return total - 1;
|
||||
}
|
||||
return begin + per - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拆分单独一个文件分片
|
||||
* @return 一个文件分片
|
||||
*/
|
||||
default ArrayList<DownloadPart> splitDownloadOneFile() {
|
||||
ArrayList<DownloadPart> parts = new ArrayList<>();
|
||||
DownloadPart part = new DownloadPart();
|
||||
part.setIndex(0);
|
||||
part.setStart(0);
|
||||
part.setEnd(-1);
|
||||
part.setFileStart(0);
|
||||
parts.add(part);
|
||||
return parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下载分片范围
|
||||
* @param range 分片
|
||||
* @param totalSize 目标文件大小
|
||||
* @return 返回分片范围
|
||||
*/
|
||||
default long[] getDownloadSlice(long[] range, long totalSize) {
|
||||
long start = 0;
|
||||
long size = totalSize;
|
||||
|
||||
if ((range == null) ||
|
||||
(range.length != 2) ||
|
||||
(totalSize < 1) ||
|
||||
(range[0] < 0 && range[1] < 0) ||
|
||||
(range[0] > 0 && range[1] > 0 && range[0] > range[1])||
|
||||
(range[0] >= totalSize)) {
|
||||
//download all
|
||||
} else {
|
||||
//dwonload part by range & total size
|
||||
long begin = range[0];
|
||||
long end = range[1];
|
||||
if (range[0] < 0) {
|
||||
begin = 0;
|
||||
}
|
||||
if (range[1] < 0 || range[1] >= totalSize) {
|
||||
end = totalSize -1;
|
||||
}
|
||||
start = begin;
|
||||
size = end - begin + 1;
|
||||
}
|
||||
|
||||
return new long[]{start, size};
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建下载缓存文件
|
||||
* @param downloadTempFile 下载缓存文件
|
||||
* @param length 文件大小
|
||||
*/
|
||||
default void createDownloadTemp(String downloadTempFile, long length) {
|
||||
File file = new File(downloadTempFile);
|
||||
RandomAccessFile rf = null;
|
||||
try {
|
||||
rf = new RandomAccessFile(file, "rw");
|
||||
rf.setLength(length);
|
||||
} catch (Exception e) {
|
||||
throw new OssException("创建下载缓存文件失败");
|
||||
} finally {
|
||||
IoUtil.close(rf);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载分片
|
||||
* @param key 目标文件
|
||||
* @param start 文件开始字节
|
||||
* @param end 文件结束字节
|
||||
* @return 此范围的文件流
|
||||
* @throws Exception 客户端异常
|
||||
*/
|
||||
default InputStream downloadPart(String key, long start, long end) throws Exception {
|
||||
throw new OssException("下载文件分片方法未实现,默认不支持此方法");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
* @param targetName 目标文件路径
|
||||
*/
|
||||
void delete(String targetName);
|
||||
|
||||
/**
|
||||
* 复制文件,默认覆盖
|
||||
* @param sourceName 源文件路径
|
||||
* @param targetName 目标文件路径
|
||||
*/
|
||||
default void copy(String sourceName, String targetName) {
|
||||
copy(sourceName, targetName, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制文件
|
||||
* @param sourceName 源文件路径
|
||||
* @param targetName 目标文件路径
|
||||
* @param isOverride 是否覆盖
|
||||
*/
|
||||
void copy(String sourceName, String targetName, Boolean isOverride);
|
||||
|
||||
/**
|
||||
* 移动文件,默认覆盖
|
||||
* @param sourceName 源文件路径
|
||||
* @param targetName 目标路径
|
||||
*/
|
||||
default void move(String sourceName, String targetName) {
|
||||
move(sourceName, targetName, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动文件
|
||||
* @param sourceName 源文件路径
|
||||
* @param targetName 目标路径
|
||||
* @param isOverride 是否覆盖
|
||||
*/
|
||||
default void move(String sourceName, String targetName, Boolean isOverride) {
|
||||
copy(sourceName, targetName, isOverride);
|
||||
delete(sourceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重命名文件
|
||||
* @param sourceName 源文件路径
|
||||
* @param targetName 目标文件路径
|
||||
*/
|
||||
default void rename(String sourceName, String targetName) {
|
||||
rename(sourceName, targetName, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重命名文件
|
||||
* @param sourceName 源文件路径
|
||||
* @param targetName 目标路径
|
||||
* @param isOverride 是否覆盖
|
||||
*/
|
||||
default void rename(String sourceName, String targetName, Boolean isOverride) {
|
||||
move(sourceName, targetName, isOverride);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件信息,默认获取目标文件信息
|
||||
* @param targetName 目标文件路径
|
||||
* @return 文件基本信息
|
||||
*/
|
||||
default OssInfo getInfo(String targetName) {
|
||||
return getInfo(targetName, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件信息
|
||||
* isRecursion传false,则只获取当前对象信息;
|
||||
* isRecursion传true,且当前对象为目录时,会递归获取当前路径下所有文件及目录,按层级返回
|
||||
* @param targetName 目标文件路径
|
||||
* @param isRecursion 是否递归
|
||||
* @return 文件基本信息
|
||||
*/
|
||||
OssInfo getInfo(String targetName, Boolean isRecursion);
|
||||
|
||||
/**
|
||||
* 是否存在
|
||||
* @param targetName 目标文件路径
|
||||
* @return true/false
|
||||
*/
|
||||
default Boolean isExist(String targetName) {
|
||||
OssInfo info = getInfo(targetName);
|
||||
return ObjectUtil.isNotEmpty(info) && ObjectUtil.isNotEmpty(info.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为文件
|
||||
* 默认根据路径最后一段名称是否有后缀名来判断是否为文件,此方式不准确,当存储平台不提供类似方法时,可使用此方法
|
||||
* @param targetName 目标文件路径
|
||||
* @return true/false
|
||||
*/
|
||||
default Boolean isFile(String targetName) {
|
||||
String name = FileNameUtil.getName(targetName);
|
||||
return StrUtil.indexOf(name, StrUtil.C_DOT) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为目录
|
||||
* 与判断是否为文件相反
|
||||
* @param targetName 目标文件路径
|
||||
* @return true/false
|
||||
*/
|
||||
default Boolean isDirectory(String targetName) {
|
||||
return !isFile(targetName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取标准的OSS客户端底层操作对象
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getClientObject();
|
||||
|
||||
/**
|
||||
* 获取完整Key
|
||||
* @param targetName 目标地址
|
||||
* @param isAbsolute 是否绝对路径
|
||||
* true:绝对路径;false:相对路径
|
||||
* @return 完整路径
|
||||
*/
|
||||
default String getKey(String targetName, Boolean isAbsolute) {
|
||||
String key = OssPathUtil.convertPath(getBasePath() + targetName, isAbsolute);
|
||||
if (FileUtil.isWindows() && isAbsolute) {
|
||||
if (key.contains(StrUtil.COLON) && key.startsWith(StrUtil.SLASH)) {
|
||||
key = key.substring(1);
|
||||
}
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件存储根路径
|
||||
* @return 根路径
|
||||
*/
|
||||
String getBasePath();
|
||||
|
||||
}
|
@@ -0,0 +1,234 @@
|
||||
package com.schisandra.oss.application.oss.core.ali;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.io.file.FileNameUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.common.utils.HttpHeaders;
|
||||
import com.aliyun.oss.model.*;
|
||||
|
||||
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
||||
import com.schisandra.oss.application.oss.core.ali.model.AliOssConfig;
|
||||
import com.schisandra.oss.application.oss.exception.OssException;
|
||||
import com.schisandra.oss.application.oss.model.DirectoryOssInfo;
|
||||
import com.schisandra.oss.application.oss.model.FileOssInfo;
|
||||
import com.schisandra.oss.application.oss.model.OssInfo;
|
||||
import com.schisandra.oss.application.oss.model.SliceConfig;
|
||||
import com.schisandra.oss.application.oss.utils.OssPathUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* https://help.aliyun.com/product/31815.html
|
||||
*
|
||||
* @author landaiqing
|
||||
* @version AliOssClient.java, v 1.1 2021/11/15 11:12 chenmin Exp $
|
||||
* Created on 2021/11/15
|
||||
*/
|
||||
@Data
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AliOssClient implements StandardOssClient {
|
||||
|
||||
public static final String OSS_OBJECT_NAME = "oss";
|
||||
|
||||
private OSS oss;
|
||||
private AliOssConfig aliOssConfig;
|
||||
|
||||
@Override
|
||||
public OssInfo upLoad(InputStream is, String targetName, Boolean isOverride) {
|
||||
String bucketName = getBucketName();
|
||||
String key = getKey(targetName, false);
|
||||
|
||||
if (isOverride || !oss.doesObjectExist(bucketName, key)) {
|
||||
oss.putObject(bucketName, key, is, new ObjectMetadata());
|
||||
}
|
||||
return getInfo(targetName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 断点续传,使用SDK断点续传API实现,底层通过分块上传实现
|
||||
*
|
||||
* @param file 本地文件
|
||||
* @param targetName 目标文件路径
|
||||
* @return 文件信息
|
||||
*/
|
||||
@Override
|
||||
public OssInfo upLoadCheckPoint(File file, String targetName) {
|
||||
try {
|
||||
String bucketName = getBucketName();
|
||||
String key = getKey(targetName, false);
|
||||
|
||||
UploadFileRequest uploadFileRequest = new UploadFileRequest(bucketName, key);
|
||||
String filePath = file.getPath();
|
||||
uploadFileRequest.setUploadFile(filePath);
|
||||
|
||||
SliceConfig slice = aliOssConfig.getSliceConfig();
|
||||
uploadFileRequest.setTaskNum(slice.getTaskNum());
|
||||
uploadFileRequest.setPartSize(slice.getPartSize());
|
||||
|
||||
uploadFileRequest.setEnableCheckpoint(true);
|
||||
|
||||
String checkpointFile = filePath + StrUtil.DOT + OssConstant.OssType.ALI;
|
||||
uploadFileRequest.setCheckpointFile(checkpointFile);
|
||||
|
||||
oss.uploadFile(uploadFileRequest);
|
||||
} catch (Throwable e) {
|
||||
throw new OssException(e);
|
||||
}
|
||||
return getInfo(targetName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downLoad(OutputStream os, String targetName) {
|
||||
String bucketName = getBucketName();
|
||||
String key = getKey(targetName, false);
|
||||
OSSObject ossObject = oss.getObject(bucketName, key);
|
||||
IoUtil.copy(ossObject.getObjectContent(), os);
|
||||
IoUtil.close(ossObject);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void downLoadCheckPoint(File localFile, String targetName) {
|
||||
String bucketName = getBucketName();
|
||||
String key = getKey(targetName, false);
|
||||
String filePath = localFile.getPath();
|
||||
|
||||
DownloadFileRequest downloadFileRequest = new DownloadFileRequest(bucketName, key);
|
||||
downloadFileRequest.setDownloadFile(filePath);
|
||||
|
||||
SliceConfig sliceConfig = aliOssConfig.getSliceConfig();
|
||||
downloadFileRequest.setPartSize(sliceConfig.getPartSize());
|
||||
downloadFileRequest.setTaskNum(sliceConfig.getTaskNum());
|
||||
downloadFileRequest.setEnableCheckpoint(true);
|
||||
|
||||
String checkpointFile = filePath + StrUtil.DOT + OssConstant.OssType.ALI;
|
||||
downloadFileRequest.setCheckpointFile(checkpointFile);
|
||||
|
||||
oss.downloadFile(downloadFileRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String targetName) {
|
||||
oss.deleteObject(getBucketName(), getKey(targetName, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(String sourceName, String targetName, Boolean isOverride) {
|
||||
String bucketName = getBucketName();
|
||||
String targetKey = getKey(targetName, false);
|
||||
if (isOverride || !oss.doesObjectExist(bucketName, targetKey)) {
|
||||
oss.copyObject(bucketName, getKey(sourceName, false), bucketName, targetKey);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public OssInfo getInfo(String targetName, Boolean isRecursion) {
|
||||
String bucketName = getBucketName();
|
||||
String key = getKey(targetName, false);
|
||||
|
||||
OssInfo ossInfo = getBaseInfo(bucketName, key);
|
||||
ossInfo.setName(StrUtil.equals(targetName, StrUtil.SLASH) ? targetName : FileNameUtil.getName(targetName));
|
||||
ossInfo.setPath(OssPathUtil.replaceKey(targetName, ossInfo.getName(), true));
|
||||
|
||||
if (isRecursion && isDirectory(key)) {
|
||||
ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucketName);
|
||||
listObjectsRequest.setDelimiter(StrUtil.SLASH);
|
||||
String prefix = OssPathUtil.convertPath(key, false);
|
||||
listObjectsRequest.setPrefix(prefix.endsWith(StrUtil.SLASH) ? prefix : prefix + StrUtil.SLASH);
|
||||
ObjectListing listing = oss.listObjects(listObjectsRequest);
|
||||
|
||||
List<OssInfo> fileOssInfos = new ArrayList<>();
|
||||
List<OssInfo> directoryInfos = new ArrayList<>();
|
||||
for (OSSObjectSummary ossObjectSummary : listing.getObjectSummaries()) {
|
||||
if (FileNameUtil.getName(ossObjectSummary.getKey()).equals(FileNameUtil.getName(key))) {
|
||||
ossInfo.setLastUpdateTime(DateUtil.date(ossObjectSummary.getLastModified()).toString(DatePattern.NORM_DATETIME_PATTERN));
|
||||
ossInfo.setCreateTime(DateUtil.date(ossObjectSummary.getLastModified()).toString(DatePattern.NORM_DATETIME_PATTERN));
|
||||
ossInfo.setLength(Convert.toStr(ossObjectSummary.getSize()));
|
||||
} else {
|
||||
fileOssInfos.add(getInfo(OssPathUtil.replaceKey(ossObjectSummary.getKey(), getBasePath(), false), false));
|
||||
}
|
||||
}
|
||||
|
||||
for (String commonPrefix : listing.getCommonPrefixes()) {
|
||||
String target = OssPathUtil.replaceKey(commonPrefix, getBasePath(), false);
|
||||
if (isDirectory(commonPrefix)) {
|
||||
directoryInfos.add(getInfo(target, true));
|
||||
} else {
|
||||
fileOssInfos.add(getInfo(target, false));
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(fileOssInfos) && fileOssInfos.get(0) instanceof FileOssInfo) {
|
||||
ReflectUtil.setFieldValue(ossInfo, "fileInfos", fileOssInfos);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(directoryInfos) && directoryInfos.get(0) instanceof DirectoryOssInfo) {
|
||||
ReflectUtil.setFieldValue(ossInfo, "directoryInfos", directoryInfos);
|
||||
}
|
||||
}
|
||||
|
||||
return ossInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isExist(String targetName) {
|
||||
return oss.doesObjectExist(getBucketName(), getKey(targetName, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBasePath() {
|
||||
return aliOssConfig.getBasePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getClientObject() {
|
||||
return new HashMap<String, Object>() {
|
||||
{
|
||||
put(OSS_OBJECT_NAME, getOss());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public String getBucketName() {
|
||||
String bucketName = aliOssConfig.getBucketName();
|
||||
if (!oss.doesBucketExist(bucketName)) {
|
||||
oss.createBucket(bucketName);
|
||||
}
|
||||
return bucketName;
|
||||
}
|
||||
|
||||
public OssInfo getBaseInfo(String bucketName, String key) {
|
||||
OssInfo ossInfo;
|
||||
|
||||
if (isFile(key)) {
|
||||
ossInfo = new FileOssInfo();
|
||||
try {
|
||||
ObjectMetadata objectMetadata = oss.getObjectMetadata(bucketName, OssPathUtil.replaceKey(key, "", false));
|
||||
ossInfo.setLastUpdateTime(DateUtil.date((Date) objectMetadata.getRawMetadata().get(HttpHeaders.LAST_MODIFIED)).toString(DatePattern.NORM_DATETIME_PATTERN));
|
||||
ossInfo.setCreateTime(DateUtil.date((Date) objectMetadata.getRawMetadata().get(HttpHeaders.DATE)).toString(DatePattern.NORM_DATETIME_PATTERN));
|
||||
ossInfo.setLength(Convert.toStr(objectMetadata.getContentLength()));
|
||||
} catch (Exception e) {
|
||||
log.error("获取{}文件属性失败", key, e);
|
||||
}
|
||||
} else {
|
||||
ossInfo = new DirectoryOssInfo();
|
||||
}
|
||||
return ossInfo;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,111 @@
|
||||
package com.schisandra.oss.application.oss.core.ali;
|
||||
|
||||
import cn.hutool.core.text.CharPool;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClient;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
|
||||
import com.aliyun.oss.common.comm.Protocol;
|
||||
import com.schisandra.oss.application.convert.SchisandraOssAliDTOConverter;
|
||||
import com.schisandra.oss.application.dto.SchisandraOssAliDTO;
|
||||
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
||||
import com.schisandra.oss.application.oss.core.ali.model.AliOssClientConfig;
|
||||
import com.schisandra.oss.application.oss.core.ali.model.AliOssConfig;
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||
import com.schisandra.oss.domain.service.SchisandraOssAliDomainService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
||||
* @version AliOssConfiguration.java, v 1.1 2021/11/16 15:25 chenmin Exp $
|
||||
* Created on 2021/11/16
|
||||
*/
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class AliOssConfiguration {
|
||||
|
||||
@Resource
|
||||
SchisandraOssAliDomainService schisandraOssAliDomainService;
|
||||
|
||||
@Bean
|
||||
public StandardOssClient aliOssClient() {
|
||||
SchisandraOssAliBO schisandraOssAliBO = schisandraOssAliDomainService.getAliOssConfig(1L);
|
||||
SchisandraOssAliDTO schisandraOssAliDTO = SchisandraOssAliDTOConverter.INSTANCE.convertBOToDTO(schisandraOssAliBO);
|
||||
if (ObjectUtils.isEmpty(schisandraOssAliDTO)) {
|
||||
log.error("ali oss配置信息获取失败");
|
||||
return null;
|
||||
}
|
||||
AliOssConfig aliOssConfig = new AliOssConfig();
|
||||
aliOssConfig.setEndpoint(schisandraOssAliDTO.getEndpoint());
|
||||
aliOssConfig.setAccessKeyId(schisandraOssAliDTO.getAccessKeyId());
|
||||
aliOssConfig.setAccessKeySecret(schisandraOssAliDTO.getAccessKeySecret());
|
||||
aliOssConfig.setSecurityToken(schisandraOssAliDTO.getSecurityToken());
|
||||
if (Boolean.parseBoolean(schisandraOssAliDTO.getOpenAdvancedSetup())) {
|
||||
AliOssClientConfig aliOssClientConfig = new AliOssClientConfig();
|
||||
aliOssClientConfig.setCnameExcludeList(Arrays.asList(Optional.ofNullable(schisandraOssAliDTO.getCnameExcludeList()).orElse("").split(",")));
|
||||
aliOssClientConfig.setConnectionTimeout(schisandraOssAliDTO.getConnectionTimeout());
|
||||
aliOssClientConfig.setConnectionTTL(schisandraOssAliDTO.getConnectionTTL());
|
||||
aliOssClientConfig.setProtocol(Protocol.valueOf(schisandraOssAliDTO.getProtocol()));
|
||||
aliOssClientConfig.setConnectionRequestTimeout(schisandraOssAliDTO.getConnectionRequestTimeout());
|
||||
aliOssClientConfig.setMaxConnections(schisandraOssAliDTO.getMaxConnections());
|
||||
aliOssClientConfig.setProxyPort(Integer.parseInt(schisandraOssAliDTO.getProxyPort()));
|
||||
aliOssClientConfig.setProxyDomain(schisandraOssAliDTO.getProxyDomain());
|
||||
aliOssClientConfig.setCrcCheckEnabled(Boolean.parseBoolean(schisandraOssAliDTO.getCrcCheckEnabled()));
|
||||
aliOssClientConfig.setTickOffset(schisandraOssAliDTO.getTickOffset());
|
||||
aliOssClientConfig.setProxyHost(schisandraOssAliDTO.getProxyHost());
|
||||
aliOssClientConfig.setProxyPassword(schisandraOssAliDTO.getProxyPassword());
|
||||
aliOssClientConfig.setProxyUsername(schisandraOssAliDTO.getProxyUsername());
|
||||
aliOssClientConfig.setVerifySSLEnable(Boolean.parseBoolean(schisandraOssAliDTO.getVerifySSLEnable()));
|
||||
aliOssClientConfig.setUseSystemPropertyValues(Boolean.parseBoolean(schisandraOssAliDTO.getUseSystemPropertyValues()));
|
||||
aliOssClientConfig.setUseReaper(Boolean.parseBoolean(schisandraOssAliDTO.getUseReaper()));
|
||||
aliOssClientConfig.setSupportCname(Boolean.parseBoolean(schisandraOssAliDTO.getSupportCname()));
|
||||
aliOssClientConfig.setSocketTimeout(schisandraOssAliDTO.getSocketTimeout());
|
||||
aliOssClientConfig.setSldEnabled(Boolean.parseBoolean(schisandraOssAliDTO.getSldEnabled()));
|
||||
aliOssClientConfig.setProxyWorkstation(schisandraOssAliDTO.getProxyWorkstation());
|
||||
aliOssClientConfig.setIdleConnectionTime(schisandraOssAliDTO.getIdleConnectionTime());
|
||||
aliOssClientConfig.setLogConnectionPoolStats(Boolean.parseBoolean(schisandraOssAliDTO.getLogConnectionPoolStats()));
|
||||
aliOssConfig.setClientConfig(aliOssClientConfig);
|
||||
}
|
||||
return aliOssClient(aliOssConfig);
|
||||
}
|
||||
|
||||
public StandardOssClient aliOssClient(AliOssConfig aliOssConfig) {
|
||||
return new AliOssClient(ossClient(aliOssConfig), aliOssConfig);
|
||||
}
|
||||
|
||||
public OSS ossClient(AliOssConfig aliOssConfig) {
|
||||
String securityToken = aliOssConfig.getSecurityToken();
|
||||
AliOssClientConfig clientConfiguration = aliOssConfig.getClientConfig();
|
||||
if (ObjectUtil.isEmpty(securityToken) && ObjectUtil.isNotEmpty(clientConfiguration)) {
|
||||
return new OSSClientBuilder().build(aliOssConfig.getEndpoint(),
|
||||
aliOssConfig.getAccessKeyId(),
|
||||
aliOssConfig.getAccessKeySecret(), clientConfiguration.toClientConfig());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(securityToken) && ObjectUtil.isEmpty(clientConfiguration)) {
|
||||
return new OSSClientBuilder().build(aliOssConfig.getEndpoint(),
|
||||
aliOssConfig.getAccessKeyId(),
|
||||
aliOssConfig.getAccessKeySecret(), securityToken);
|
||||
}
|
||||
return new OSSClientBuilder().build(aliOssConfig.getEndpoint(),
|
||||
aliOssConfig.getAccessKeyId(),
|
||||
aliOssConfig.getAccessKeySecret(), securityToken,
|
||||
Optional.ofNullable(clientConfiguration).orElse(new AliOssClientConfig()).toClientConfig());
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,159 @@
|
||||
package com.schisandra.oss.application.oss.core.ali.model;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.aliyun.oss.ClientBuilderConfiguration;
|
||||
import com.aliyun.oss.common.comm.Protocol;
|
||||
import com.aliyun.oss.common.comm.SignVersion;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.aliyun.oss.ClientConfiguration.*;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
||||
* @version AliOssClientConfig.java, v 1.0 2022/4/20 16:12 chenmin Exp $
|
||||
* Created on 2022/4/20
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AliOssClientConfig {
|
||||
/**
|
||||
* 用户代理,指HTTP的User-Agent头。默认为aliyun-sdk-java。
|
||||
*/
|
||||
private String userAgent = DEFAULT_USER_AGENT;
|
||||
/**
|
||||
* 请求失败后最大的重试次数。默认3次。
|
||||
*/
|
||||
private int maxErrorRetry = DEFAULT_MAX_RETRIES;
|
||||
/**
|
||||
* 从连接池中获取连接的超时时间(单位:毫秒)。默认不超时。
|
||||
*/
|
||||
private int connectionRequestTimeout = DEFAULT_CONNECTION_REQUEST_TIMEOUT;
|
||||
/**
|
||||
* 建立连接的超时时间(单位:毫秒)。默认为50000毫秒。
|
||||
*/
|
||||
private int connectionTimeout = DEFAULT_CONNECTION_TIMEOUT;
|
||||
/**
|
||||
* Socket层传输数据的超时时间(单位:毫秒)。默认为50000毫秒。
|
||||
*/
|
||||
private int socketTimeout = DEFAULT_SOCKET_TIMEOUT;
|
||||
/**
|
||||
* 允许打开的最大HTTP连接数。默认为1024
|
||||
*/
|
||||
private int maxConnections = DEFAULT_MAX_CONNECTIONS;
|
||||
/**
|
||||
* 连接TTL (生存时间)。Http连接由连接管理器用TTL缓存。
|
||||
*/
|
||||
private long connectionTTL = DEFAULT_CONNECTION_TTL;
|
||||
/**
|
||||
* 是否使用com.aliyun.oss.common.comm.IdleConnectionReaper管理过期连接,默认开启
|
||||
*/
|
||||
private boolean useReaper = DEFAULT_USE_REAPER;
|
||||
/**
|
||||
* 连接空闲超时时间,超时则关闭连接(单位:毫秒)。默认为60000毫秒。
|
||||
*/
|
||||
private long idleConnectionTime = DEFAULT_IDLE_CONNECTION_TIME;
|
||||
/**
|
||||
* 连接OSS所采用的协议(HTTP或HTTPS),默认为HTTP。
|
||||
*/
|
||||
private Protocol protocol = Protocol.HTTP;
|
||||
/**
|
||||
* 代理服务器主机地址。
|
||||
*/
|
||||
private String proxyHost = null;
|
||||
/**
|
||||
* 代理服务器端口。
|
||||
*/
|
||||
private int proxyPort = -1;
|
||||
/**
|
||||
* 代理服务器验证的用户名。
|
||||
*/
|
||||
private String proxyUsername = null;
|
||||
/**
|
||||
* 代理服务器验证的密码。
|
||||
*/
|
||||
private String proxyPassword = null;
|
||||
/**
|
||||
* 代理服务器的域,该域可以执行NTLM认证
|
||||
*/
|
||||
private String proxyDomain = null;
|
||||
/**
|
||||
* 代理主机的NTLM身份验证服务器
|
||||
*/
|
||||
private String proxyWorkstation = null;
|
||||
/**
|
||||
* 是否支持CNAME作为Endpoint,默认支持CNAME。
|
||||
*/
|
||||
private boolean supportCname = false;
|
||||
/**
|
||||
* 设置不可变排除的CName列表 ---- 任何以该列表中的项目结尾的域都不会进行Cname解析。
|
||||
*/
|
||||
private List<String> cnameExcludeList = new ArrayList<String>();
|
||||
/**
|
||||
* 是否开启二级域名(Second Level Domain)的访问方式,默认不开启。
|
||||
*/
|
||||
private boolean sldEnabled = false;
|
||||
/**
|
||||
* 请求超时时间,单位:毫秒。默认情况下是5分钟。
|
||||
*/
|
||||
private int requestTimeout = DEFAULT_REQUEST_TIMEOUT;
|
||||
/**
|
||||
* 是否启用请求超时校验。默认情况下,它是禁用的。
|
||||
*/
|
||||
private boolean requestTimeoutEnabled = false;
|
||||
/**
|
||||
* 设置慢请求的延迟阈值。如果请求的延迟大于延迟,则将记录该请求。默认情况下,阈值为5分钟。
|
||||
*/
|
||||
private long slowRequestsThreshold = DEFAULT_SLOW_REQUESTS_THRESHOLD;
|
||||
/**
|
||||
* 设置默认的http头。所有请求头将自动添加到每个请求中。如果在请求中也指定了相同的请求头,则默认的标头将被覆盖。
|
||||
*/
|
||||
private Map<String, String> defaultHeaders = new LinkedHashMap<String, String>();
|
||||
/**
|
||||
* 是否在上传和下载时启用CRC校验,默认启用
|
||||
*/
|
||||
private boolean crcCheckEnabled = true;
|
||||
/**
|
||||
* 所有请求设置签名版本
|
||||
*/
|
||||
private SignVersion signatureVersion = DEFAULT_SIGNATURE_VERSION;
|
||||
/**
|
||||
* 设置OSS服务端时间和本地时间之间的差异,以毫秒为单位。
|
||||
*/
|
||||
private long tickOffset = 0;
|
||||
/**
|
||||
* 是否开启HTTP重定向。
|
||||
* 说明: Java SDK 3.10.1及以上版本支持设置是否开启HTTP重定向,默认开启。
|
||||
*/
|
||||
private boolean redirectEnable = true;
|
||||
/**
|
||||
* 是否开启SSL证书校验。
|
||||
* 说明: Java SDK 3.10.1及以上版本支持设置是否开启SSL证书校验,默认开启。
|
||||
*/
|
||||
private boolean verifySSLEnable = true;
|
||||
/**
|
||||
* 是否开启日志记录连接池统计信息
|
||||
*/
|
||||
private boolean logConnectionPoolStats = false;
|
||||
/**
|
||||
* 是否使用系统属性值
|
||||
*/
|
||||
private boolean useSystemPropertyValues = false;
|
||||
|
||||
public ClientBuilderConfiguration toClientConfig() {
|
||||
ClientBuilderConfiguration clientConfig = new ClientBuilderConfiguration();
|
||||
BeanUtil.copyProperties(this, clientConfig, "proxyPort", "tickOffset");
|
||||
if (this.proxyPort != -1) {
|
||||
clientConfig.setProxyPort(this.proxyPort);
|
||||
}
|
||||
if (this.tickOffset != 0) {
|
||||
clientConfig.setTickOffset(this.tickOffset);
|
||||
}
|
||||
return clientConfig;
|
||||
}
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
package com.schisandra.oss.application.oss.core.ali.model;
|
||||
|
||||
|
||||
import com.schisandra.oss.application.oss.model.SliceConfig;
|
||||
import com.schisandra.oss.application.oss.utils.OssPathUtil;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
||||
* @version AliGroupInfo.java, v 1.1 2022/2/18 17:48 chenmin Exp $
|
||||
* Created on 2022/2/18
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode
|
||||
public class AliOssConfig {
|
||||
/**
|
||||
* 数据存储路径
|
||||
*/
|
||||
private String basePath;
|
||||
/**
|
||||
* Bucket名称
|
||||
*/
|
||||
private String bucketName;
|
||||
/**
|
||||
* OSS地址
|
||||
*/
|
||||
private String endpoint;
|
||||
/**
|
||||
* AccessKey ID
|
||||
*/
|
||||
private String accessKeyId;
|
||||
/**
|
||||
* AccessKey Secret
|
||||
*/
|
||||
private String accessKeySecret;
|
||||
|
||||
private String securityToken;
|
||||
|
||||
private AliOssClientConfig clientConfig;
|
||||
|
||||
/**
|
||||
* 断点续传参数
|
||||
*/
|
||||
private SliceConfig sliceConfig = new SliceConfig();
|
||||
|
||||
public void init() {
|
||||
this.sliceConfig.init();
|
||||
basePath = OssPathUtil.valid(basePath);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,284 @@
|
||||
package com.schisandra.oss.application.oss.core.minio;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.io.file.FileNameUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.aliyun.oss.common.utils.HttpHeaders;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
||||
import com.schisandra.oss.application.oss.core.minio.model.MinioOssConfig;
|
||||
import com.schisandra.oss.application.oss.exception.OssException;
|
||||
import com.schisandra.oss.application.oss.model.DirectoryOssInfo;
|
||||
import com.schisandra.oss.application.oss.model.FileOssInfo;
|
||||
import com.schisandra.oss.application.oss.model.OssInfo;
|
||||
import com.schisandra.oss.application.oss.model.download.DownloadCheckPoint;
|
||||
import com.schisandra.oss.application.oss.model.download.DownloadObjectStat;
|
||||
import com.schisandra.oss.application.oss.utils.OssPathUtil;
|
||||
import io.minio.*;
|
||||
import io.minio.messages.Item;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.Headers;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* http://docs.minio.org.cn/docs/master/minio-monitoring-guide
|
||||
* https://docs.min.io/
|
||||
*
|
||||
* @author landaiqing
|
||||
* @version MinioOssClient.java, v 1.1 2021/11/24 15:35 chenmin Exp $
|
||||
* Created on 2021/11/24
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Component
|
||||
public class MinioOssClient implements StandardOssClient {
|
||||
|
||||
public static final String MINIO_OBJECT_NAME = "minioClient";
|
||||
|
||||
private MinioClient minioClient;
|
||||
private MinioOssConfig minioOssConfig;
|
||||
|
||||
@Override
|
||||
public OssInfo upLoad(InputStream is, String targetName, Boolean isOverride) {
|
||||
try {
|
||||
String bucket = getBucket();
|
||||
String key = getKey(targetName, true);
|
||||
minioClient.putObject(PutObjectArgs.builder()
|
||||
.bucket(bucket)
|
||||
.object(key)
|
||||
.stream(is, is.available(), -1)
|
||||
.build());
|
||||
} catch (Exception e) {
|
||||
throw new OssException(e);
|
||||
}
|
||||
return getInfo(targetName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OssInfo upLoadCheckPoint(File file, String targetName) {
|
||||
try (InputStream inputStream = FileUtil.getInputStream(file)) {
|
||||
upLoad(inputStream, targetName, true);
|
||||
} catch (Exception e) {
|
||||
throw new OssException(e);
|
||||
}
|
||||
return getInfo(targetName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downLoad(OutputStream os, String targetName) {
|
||||
GetObjectResponse is = null;
|
||||
try {
|
||||
GetObjectArgs getObjectArgs = GetObjectArgs.builder()
|
||||
.bucket(getBucket())
|
||||
.object(getKey(targetName, true))
|
||||
.build();
|
||||
is = minioClient.getObject(getObjectArgs);
|
||||
ByteStreams.copy(is, os);
|
||||
} catch (Exception e) {
|
||||
throw new OssException(e);
|
||||
} finally {
|
||||
IoUtil.close(is);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downLoadCheckPoint(File localFile, String targetName) {
|
||||
downLoadFile(localFile, targetName, minioOssConfig.getSliceConfig(), OssConstant.OssType.MINIO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DownloadObjectStat getDownloadObjectStat(String targetName) {
|
||||
try {
|
||||
StatObjectArgs statObjectArgs = StatObjectArgs.builder().bucket(getBucket()).object(getKey(targetName, true)).build();
|
||||
StatObjectResponse statObjectResponse = minioClient.statObject(statObjectArgs);
|
||||
long contentLength = statObjectResponse.size();
|
||||
String eTag = statObjectResponse.etag();
|
||||
return new DownloadObjectStat().setSize(contentLength)
|
||||
.setLastModified(Date.from(statObjectResponse.lastModified().toInstant())).setDigest(eTag);
|
||||
} catch (Exception e) {
|
||||
throw new OssException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareDownload(DownloadCheckPoint downloadCheckPoint, File localFile, String targetName, String checkpointFile) {
|
||||
downloadCheckPoint.setMagic(DownloadCheckPoint.DOWNLOAD_MAGIC);
|
||||
downloadCheckPoint.setDownloadFile(localFile.getPath());
|
||||
downloadCheckPoint.setBucketName(getBucket());
|
||||
downloadCheckPoint.setKey(getKey(targetName, false));
|
||||
downloadCheckPoint.setCheckPointFile(checkpointFile);
|
||||
|
||||
downloadCheckPoint.setObjectStat(getDownloadObjectStat(targetName));
|
||||
|
||||
long downloadSize;
|
||||
if (downloadCheckPoint.getObjectStat().getSize() > 0) {
|
||||
Long partSize = minioOssConfig.getSliceConfig().getPartSize();
|
||||
long[] slice = getDownloadSlice(new long[0], downloadCheckPoint.getObjectStat().getSize());
|
||||
downloadCheckPoint.setDownloadParts(splitDownloadFile(slice[0], slice[1], partSize));
|
||||
downloadSize = slice[1];
|
||||
} else {
|
||||
//download whole file
|
||||
downloadSize = 0;
|
||||
downloadCheckPoint.setDownloadParts(splitDownloadOneFile());
|
||||
}
|
||||
downloadCheckPoint.setOriginPartSize(downloadCheckPoint.getDownloadParts().size());
|
||||
createDownloadTemp(downloadCheckPoint.getTempDownloadFile(), downloadSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream downloadPart(String key, long start, long end) throws Exception {
|
||||
GetObjectArgs getObjectArgs = GetObjectArgs.builder()
|
||||
.bucket(getBucket())
|
||||
.object(key)
|
||||
// 起始字节的位置
|
||||
.offset(start)
|
||||
// 要读取的长度 (可选,如果无值则代表读到文件结尾)。
|
||||
.length(end)
|
||||
.build();
|
||||
return minioClient.getObject(getObjectArgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String targetName) {
|
||||
try {
|
||||
RemoveObjectArgs removeObjectArgs = RemoveObjectArgs.builder()
|
||||
.bucket(getBucket())
|
||||
.object(getKey(targetName, true))
|
||||
.build();
|
||||
minioClient.removeObject(removeObjectArgs);
|
||||
} catch (Exception e) {
|
||||
throw new OssException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(String sourceName, String targetName, Boolean isOverride) {
|
||||
try {
|
||||
CopyObjectArgs copyObjectArgs = CopyObjectArgs.builder()
|
||||
.bucket(getBucket())
|
||||
.object(getKey(targetName, true))
|
||||
.source(CopySource.builder()
|
||||
.bucket(getBucket())
|
||||
.object(getKey(sourceName, true))
|
||||
.build())
|
||||
.build();
|
||||
minioClient.copyObject(copyObjectArgs);
|
||||
} catch (Exception e) {
|
||||
throw new OssException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public OssInfo getInfo(String targetName, Boolean isRecursion) {
|
||||
try {
|
||||
String key = getKey(targetName, false);
|
||||
|
||||
OssInfo ossInfo = getBaseInfo(targetName);
|
||||
if (isRecursion && isDirectory(key)) {
|
||||
|
||||
String prefix = OssPathUtil.convertPath(key, true);
|
||||
ListObjectsArgs listObjectsArgs = ListObjectsArgs.builder()
|
||||
.bucket(getBucket())
|
||||
.delimiter(StrUtil.SLASH)
|
||||
.prefix(prefix.endsWith(StrUtil.SLASH) ? prefix : prefix + StrUtil.SLASH)
|
||||
.build();
|
||||
Iterable<Result<Item>> results = minioClient.listObjects(listObjectsArgs);
|
||||
|
||||
List<OssInfo> fileOssInfos = new ArrayList<>();
|
||||
List<OssInfo> directoryInfos = new ArrayList<>();
|
||||
|
||||
for (Result<Item> result : results) {
|
||||
Item item = result.get();
|
||||
String childKey = OssPathUtil.replaceKey(item.objectName(), getBasePath(), true);
|
||||
if (item.isDir()) {
|
||||
directoryInfos.add(getInfo(childKey, true));
|
||||
} else {
|
||||
fileOssInfos.add(getInfo(childKey, false));
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(fileOssInfos) && fileOssInfos.get(0) instanceof FileOssInfo) {
|
||||
ReflectUtil.setFieldValue(ossInfo, "fileInfos", fileOssInfos);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(directoryInfos) && directoryInfos.get(0) instanceof DirectoryOssInfo) {
|
||||
ReflectUtil.setFieldValue(ossInfo, "directoryInfos", directoryInfos);
|
||||
}
|
||||
}
|
||||
return ossInfo;
|
||||
} catch (Exception e) {
|
||||
throw new OssException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBasePath() {
|
||||
return minioOssConfig.getBasePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getClientObject() {
|
||||
return new HashMap<String, Object>() {
|
||||
{
|
||||
put(MINIO_OBJECT_NAME, getMinioClient());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private String getBucket() {
|
||||
String bucketName = minioOssConfig.getBucketName();
|
||||
try {
|
||||
if (!minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build())) {
|
||||
minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return bucketName;
|
||||
}
|
||||
|
||||
public OssInfo getBaseInfo(String targetName) {
|
||||
String key = getKey(targetName, true);
|
||||
OssInfo ossInfo;
|
||||
String bucketName = getBucket();
|
||||
if (isFile(key)) {
|
||||
ossInfo = new FileOssInfo();
|
||||
try {
|
||||
GetObjectArgs getObjectArgs = GetObjectArgs.builder().bucket(bucketName).object(key).build();
|
||||
GetObjectResponse objectResponse = minioClient.getObject(getObjectArgs);
|
||||
Headers headers = objectResponse.headers();
|
||||
|
||||
ossInfo.setCreateTime(DateUtil.date(headers.getDate(HttpHeaders.DATE)).toString(DatePattern.NORM_DATETIME_PATTERN));
|
||||
ossInfo.setLastUpdateTime(DateUtil.date(headers.getDate(HttpHeaders.LAST_MODIFIED)).toString(DatePattern.NORM_DATETIME_PATTERN));
|
||||
ossInfo.setLength(Convert.toStr(headers.get(HttpHeaders.CONTENT_LENGTH)));
|
||||
} catch (Exception e) {
|
||||
log.error("获取{}文件属性失败", key, e);
|
||||
}
|
||||
} else {
|
||||
ossInfo = new DirectoryOssInfo();
|
||||
}
|
||||
ossInfo.setName(StrUtil.equals(targetName, StrUtil.SLASH) ? targetName : FileNameUtil.getName(targetName));
|
||||
ossInfo.setPath(OssPathUtil.replaceKey(targetName, ossInfo.getName(), true));
|
||||
return ossInfo;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,84 @@
|
||||
package com.schisandra.oss.application.oss.core.minio;
|
||||
|
||||
import com.schisandra.oss.application.convert.SchisandraOssMinioDTOConverter;
|
||||
import com.schisandra.oss.application.dto.SchisandraOssMinioDTO;
|
||||
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
||||
import com.schisandra.oss.application.oss.core.minio.model.MinioOssClientConfig;
|
||||
import com.schisandra.oss.application.oss.core.minio.model.MinioOssConfig;
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssMinioBO;
|
||||
import com.schisandra.oss.domain.service.SchisandraOssMinioDomainService;
|
||||
import io.minio.MinioClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
||||
* @version MinioConfiguration.java, v 1.1 2021/11/24 15:20 chenmin Exp $
|
||||
* Created on 2021/11/24
|
||||
*/
|
||||
//@Configuration
|
||||
@Slf4j
|
||||
public class MinioOssConfiguration {
|
||||
|
||||
@Resource
|
||||
private SchisandraOssMinioDomainService schisandraOssMinioDomainService;
|
||||
|
||||
// @Bean
|
||||
public StandardOssClient minioOssClient() {
|
||||
SchisandraOssMinioBO minioBO = schisandraOssMinioDomainService.getMinioConfig(1L);
|
||||
SchisandraOssMinioDTO minio = SchisandraOssMinioDTOConverter.INSTANCE.convertBOToDTO(minioBO);
|
||||
if (ObjectUtils.isEmpty(minio)) {
|
||||
log.error("minio配置信息获取失败");
|
||||
}
|
||||
MinioOssConfig minioOssConfig = new MinioOssConfig();
|
||||
minioOssConfig.setBasePath(minio.getBasePath());
|
||||
minioOssConfig.setBucketName(minio.getBucketName());
|
||||
minioOssConfig.setAccessKey(minio.getAccessKey());
|
||||
minioOssConfig.setSecretKey(minio.getSecretKey());
|
||||
minioOssConfig.setEndpoint(minio.getEndpoint());
|
||||
minioOssConfig.init();
|
||||
if (Boolean.parseBoolean(minio.getOpenAdvancedSetup())) {
|
||||
MinioOssClientConfig minioOssClientConfig = new MinioOssClientConfig();
|
||||
minioOssClientConfig.setWriteTimeout(minio.getWriteTimeout());
|
||||
minioOssClientConfig.setConnectTimeout(minio.getConnectTimeout());
|
||||
minioOssClientConfig.setReadTimeout(minio.getReadTimeout());
|
||||
minioOssClientConfig.setFollowSslRedirects(Boolean.parseBoolean(minio.getFollowSslRedirects()));
|
||||
minioOssClientConfig.setRetryOnConnectionFailure(Boolean.parseBoolean(minio.getRetryOnConnectionFailure()));
|
||||
minioOssClientConfig.setPingInterval(minio.getPingInterval());
|
||||
minioOssClientConfig.setFollowRedirects(Boolean.parseBoolean(minio.getFollowRedirects()));
|
||||
minioOssClientConfig.setCallTimeout(minio.getCallTimeout());
|
||||
minioOssConfig.setClientConfig(minioOssClientConfig);
|
||||
}
|
||||
return minioOssClient(minioOssConfig);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public StandardOssClient minioOssClient(MinioOssConfig minioOssConfig) {
|
||||
return new MinioOssClient(minioClient(minioOssConfig), minioOssConfig);
|
||||
}
|
||||
|
||||
public MinioClient minioClient(MinioOssConfig minioOssConfig) {
|
||||
MinioOssClientConfig clientConfig = minioOssConfig.getClientConfig();
|
||||
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
||||
.connectTimeout(clientConfig.getConnectTimeout(), TimeUnit.MILLISECONDS)
|
||||
.writeTimeout(clientConfig.getWriteTimeout(), TimeUnit.MILLISECONDS)
|
||||
.readTimeout(clientConfig.getReadTimeout(), TimeUnit.MILLISECONDS)
|
||||
.callTimeout(clientConfig.getCallTimeout(), TimeUnit.MILLISECONDS)
|
||||
.followRedirects(clientConfig.isFollowRedirects())
|
||||
.followSslRedirects(clientConfig.isFollowSslRedirects())
|
||||
.retryOnConnectionFailure(clientConfig.isRetryOnConnectionFailure())
|
||||
.pingInterval(clientConfig.getPingInterval(), TimeUnit.MILLISECONDS)
|
||||
.build();
|
||||
return MinioClient.builder()
|
||||
.endpoint(minioOssConfig.getEndpoint())
|
||||
.credentials(minioOssConfig.getAccessKey(), minioOssConfig.getSecretKey())
|
||||
.httpClient(okHttpClient)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
package com.schisandra.oss.application.oss.core.minio.model;
|
||||
|
||||
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
||||
* @version MinioOssClientConfig.java, v 1.0 2022/3/24 9:59 chenmin Exp $
|
||||
* Created on 2022/3/24
|
||||
*/
|
||||
@Data
|
||||
public class MinioOssClientConfig implements Serializable {
|
||||
/**
|
||||
* 连接超时时间(单位:毫秒)
|
||||
*/
|
||||
private Long connectTimeout = OssConstant.DEFAULT_CONNECTION_TIMEOUT;
|
||||
/**
|
||||
* 写超时时间(单位:毫秒)
|
||||
*/
|
||||
private Long writeTimeout = OssConstant.DEFAULT_CONNECTION_TIMEOUT;
|
||||
/**
|
||||
* 读超时时间(单位:毫秒)
|
||||
*/
|
||||
private Long readTimeout = OssConstant.DEFAULT_CONNECTION_TIMEOUT;
|
||||
/**
|
||||
* 调用超时时间(单位:毫秒)
|
||||
*/
|
||||
private Long callTimeout = (long) Integer.MAX_VALUE;
|
||||
/**
|
||||
* 是否支持重定向,默认支持
|
||||
*/
|
||||
private boolean followRedirects = true;
|
||||
/**
|
||||
* 是否支持HTTP到HTTPS,HTTPS到HTTP的重定向,默认支持
|
||||
*/
|
||||
private boolean followSslRedirects = true;
|
||||
/**
|
||||
* 是否开始连接失败重试,默认不支持
|
||||
*/
|
||||
private boolean retryOnConnectionFailure = false;
|
||||
/**
|
||||
* 连接健康检测间隔时长(单位:毫秒)
|
||||
*/
|
||||
private int pingInterval;
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
package com.schisandra.oss.application.oss.core.minio.model;
|
||||
|
||||
|
||||
import com.schisandra.oss.application.oss.model.SliceConfig;
|
||||
import com.schisandra.oss.application.oss.utils.OssPathUtil;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
||||
* @version MinioOssConfig.java, v 1.1 2022/2/20 8:58 chenmin Exp $
|
||||
* Created on 2022/2/20
|
||||
*/
|
||||
@Data
|
||||
public class MinioOssConfig implements Serializable {
|
||||
|
||||
private String basePath;
|
||||
private String endpoint;
|
||||
private String accessKey;
|
||||
private String secretKey;
|
||||
private String bucketName;
|
||||
|
||||
private MinioOssClientConfig clientConfig = new MinioOssClientConfig();
|
||||
|
||||
/**
|
||||
* 断点续传参数
|
||||
*/
|
||||
private SliceConfig sliceConfig = new SliceConfig();
|
||||
|
||||
public void init() {
|
||||
this.sliceConfig.init();
|
||||
basePath = OssPathUtil.valid(basePath);
|
||||
}
|
||||
}
|
@@ -1,4 +1,6 @@
|
||||
package com.schisandra.oss.application.oss.constant;
|
||||
package com.schisandra.oss.application.oss.enums;
|
||||
|
||||
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
@@ -0,0 +1,28 @@
|
||||
package com.schisandra.oss.application.oss.exception;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
||||
* @version DuplicateException.java, v 1.1 2021/11/15 15:27 chenmin Exp $
|
||||
* Created on 2021/11/15
|
||||
*/
|
||||
public class DuplicateException extends OssException {
|
||||
public DuplicateException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public DuplicateException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public DuplicateException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public DuplicateException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
protected DuplicateException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package com.schisandra.oss.application.oss.exception;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
||||
* @version NotSupportException.java, v 1.1 2021/12/3 15:04 chenmin Exp $
|
||||
* Created on 2021/12/3
|
||||
*/
|
||||
public class NotSupportException extends OssException {
|
||||
public NotSupportException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public NotSupportException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public NotSupportException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public NotSupportException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
protected NotSupportException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package com.schisandra.oss.application.oss.exception;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
||||
* @version OssException.java, v 1.1 2021/12/3 21:02 chenmin Exp $
|
||||
* Created on 2021/12/3
|
||||
*/
|
||||
public class OssException extends RuntimeException {
|
||||
public OssException() {
|
||||
}
|
||||
|
||||
public OssException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public OssException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public OssException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public OssException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package com.schisandra.oss.application.oss.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件夹信息对象
|
||||
* @author landaiqing
|
||||
* @version DirectoryInfo.java, v 1.1 2021/11/15 10:21 chenmin Exp $
|
||||
* Created on 2021/11/15
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class DirectoryOssInfo extends OssInfo {
|
||||
|
||||
/**
|
||||
* 文件夹列表
|
||||
*/
|
||||
private List<FileOssInfo> fileInfos = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 文件列表
|
||||
*/
|
||||
private List<DirectoryOssInfo> directoryInfos = new ArrayList<>();
|
||||
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package com.schisandra.oss.application.oss.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 文件信息对象
|
||||
* @author landaiqing
|
||||
* @version FileInfo.java, v 1.1 2021/11/15 10:19 chenmin Exp $
|
||||
* Created on 2021/11/15
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class FileOssInfo extends OssInfo {
|
||||
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package com.schisandra.oss.application.oss.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
||||
* @version Info.java, v 1.1 2021/11/15 10:16 chenmin Exp $
|
||||
* Created on 2021/11/15
|
||||
*/
|
||||
@Data
|
||||
public class OssInfo {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 存储路径
|
||||
*/
|
||||
private String path;
|
||||
/**
|
||||
* 对象大小
|
||||
*/
|
||||
private String length;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
/**
|
||||
* 最新修改时间
|
||||
*/
|
||||
private String lastUpdateTime;
|
||||
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
package com.schisandra.oss.application.oss.model;
|
||||
|
||||
|
||||
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 断点续传参数
|
||||
* @author landaiqing
|
||||
* @version Slice.java, v 1.1 2022/2/10 17:09 chenmin Exp $
|
||||
* Created on 2022/2/10
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SliceConfig {
|
||||
/**
|
||||
* 分片大小,默认5MB
|
||||
*/
|
||||
private Long partSize = OssConstant.DEFAULT_PART_SIZE;
|
||||
|
||||
/**
|
||||
* 并发线程数,默认等于CPU的核数
|
||||
*/
|
||||
private Integer taskNum = OssConstant.DEFAULT_TASK_NUM;
|
||||
|
||||
public void init() {
|
||||
if (this.getPartSize() <= 0) {
|
||||
log.warn("断点续传——分片大小必须大于0");
|
||||
this.setPartSize(OssConstant.DEFAULT_PART_SIZE);
|
||||
}
|
||||
if (this.getTaskNum() <= 0) {
|
||||
log.warn("断点续传——并发线程数必须大于0");
|
||||
this.setTaskNum(OssConstant.DEFAULT_TASK_NUM);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,121 @@
|
||||
package com.schisandra.oss.application.oss.model.download;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
||||
* @version DownloadCheckPoint.java, v 1.1 2022/2/21 15:14 chenmin Exp $
|
||||
* Created on 2022/2/21
|
||||
*/
|
||||
@Data
|
||||
public class DownloadCheckPoint implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4682293344365787077L;
|
||||
public static final String DOWNLOAD_MAGIC = "92611BED-89E2-46B6-89E5-72F273D4B0A3";
|
||||
|
||||
private String magic;
|
||||
private int md5;
|
||||
private String downloadFile;
|
||||
private String bucketName;
|
||||
private String key;
|
||||
private String checkPointFile;
|
||||
private DownloadObjectStat objectStat;
|
||||
private List<DownloadPart> downloadParts = Collections.synchronizedList(new ArrayList<>());
|
||||
private long originPartSize;
|
||||
|
||||
/**
|
||||
* 从缓存文件中加载断点数据
|
||||
* @param checkPointFile 断点续传进度记录文件
|
||||
*/
|
||||
public synchronized void load(String checkPointFile) throws IOException, ClassNotFoundException {
|
||||
InputStream inputStream = FileUtil.getInputStream(checkPointFile);
|
||||
ObjectInputStream objectInputStream = new ObjectInputStream(inputStream);
|
||||
DownloadCheckPoint dcp = (DownloadCheckPoint) objectInputStream.readObject();
|
||||
assign(dcp);
|
||||
IoUtil.close(objectInputStream);
|
||||
IoUtil.close(inputStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将断点信息写入到断点缓存文件
|
||||
*/
|
||||
public synchronized void dump() throws IOException {
|
||||
this.md5 = hashCode();
|
||||
FileOutputStream outputStream = new FileOutputStream(checkPointFile);
|
||||
ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
|
||||
objectOutputStream.writeObject(this);
|
||||
IoUtil.close(objectOutputStream);
|
||||
IoUtil.close(outputStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下载缓存文件名称
|
||||
* @return 缓存文件名
|
||||
*/
|
||||
public String getTempDownloadFile() {
|
||||
return downloadFile + ".tmp";
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新分片状态
|
||||
* @param index 分片索引
|
||||
* @param completed 对应分片是否完成
|
||||
*/
|
||||
public synchronized void update(int index, boolean completed) {
|
||||
downloadParts.get(index).setCompleted(completed);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验下载文件与断点信息是否一致
|
||||
* @param objectStat 文件状态
|
||||
* @return 校验是否通过
|
||||
*/
|
||||
public synchronized boolean isValid(DownloadObjectStat objectStat) {
|
||||
// 比较checkpoint的magic和md5
|
||||
if (this.magic == null || !this.magic.equals(DOWNLOAD_MAGIC) || this.md5 != hashCode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 比较文件大小及最新修改时间
|
||||
if (this.objectStat.getSize() != objectStat.getSize() || !this.objectStat.getLastModified().equals(objectStat.getLastModified())
|
||||
|| !this.objectStat.getDigest().equals(objectStat.getDigest())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((bucketName == null) ? 0 : bucketName.hashCode());
|
||||
result = prime * result + ((downloadFile == null) ? 0 : downloadFile.hashCode());
|
||||
result = prime * result + ((checkPointFile == null) ? 0 : checkPointFile.hashCode());
|
||||
result = prime * result + ((magic == null) ? 0 : magic.hashCode());
|
||||
result = prime * result + ((key == null) ? 0 : key.hashCode());
|
||||
result = prime * result + ((objectStat == null) ? 0 : objectStat.hashCode());
|
||||
result = prime * result + ((downloadParts == null) ? 0 : downloadParts.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
private void assign(DownloadCheckPoint dcp) {
|
||||
this.setMagic(dcp.getMagic());
|
||||
this.setMd5(dcp.getMd5());
|
||||
this.setDownloadFile(dcp.getDownloadFile());
|
||||
this.setCheckPointFile(dcp.getCheckPointFile());
|
||||
this.setBucketName(dcp.getBucketName());
|
||||
this.setKey(dcp.getKey());
|
||||
this.setObjectStat(dcp.getObjectStat());
|
||||
this.setDownloadParts(dcp.getDownloadParts());
|
||||
this.setOriginPartSize(dcp.getOriginPartSize());
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package com.schisandra.oss.application.oss.model.download;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
||||
* @version ObjectStat.java, v 1.1 2022/2/21 15:15 chenmin Exp $
|
||||
* Created on 2022/2/21
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class DownloadObjectStat implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2883494783412999919L;
|
||||
|
||||
private long size;
|
||||
private Date lastModified;
|
||||
private String digest;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((digest == null) ? 0 : digest.hashCode());
|
||||
result = prime * result + ((lastModified == null) ? 0 : lastModified.hashCode());
|
||||
result = prime * result + (int) (size ^ (size >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package com.schisandra.oss.application.oss.model.download;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
||||
* @version DownloadPart.java, v 1.1 2022/2/21 15:15 chenmin Exp $
|
||||
* Created on 2022/2/21
|
||||
*/
|
||||
@Data
|
||||
public class DownloadPart implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3655925846487976207L;
|
||||
|
||||
private int index;
|
||||
private long start;
|
||||
private long end;
|
||||
private boolean isCompleted;
|
||||
private long length;
|
||||
private long crc;
|
||||
private long fileStart;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + index;
|
||||
result = prime * result + (isCompleted ? 1231 : 1237);
|
||||
result = prime * result + (int) (end ^ (end >>> 32));
|
||||
result = prime * result + (int) (start ^ (start >>> 32));
|
||||
result = prime * result + (int) (crc ^ (crc >>> 32));
|
||||
result = prime * result + (int) (fileStart ^ (fileStart >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
package com.schisandra.oss.application.oss.model.download;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
||||
* @version PartResult.java, v 1.1 2022/2/21 15:17 chenmin Exp $
|
||||
* Created on 2022/2/21
|
||||
*/
|
||||
@Data
|
||||
public class DownloadPartResult {
|
||||
|
||||
private int number;
|
||||
private long start;
|
||||
private long end;
|
||||
private boolean failed = false;
|
||||
private Exception exception;
|
||||
private Long clientCrc;
|
||||
private Long serverCrc;
|
||||
private long length;
|
||||
|
||||
public DownloadPartResult(int number, long start, long end) {
|
||||
this.number = number;
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
public DownloadPartResult(int number, long start, long end, long length, long clientCrc) {
|
||||
this.number = number;
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.length = length;
|
||||
this.clientCrc = clientCrc;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,130 @@
|
||||
package com.schisandra.oss.application.oss.model.upload;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
||||
import com.schisandra.oss.application.oss.exception.OssException;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 断点对象
|
||||
* @author landaiqing
|
||||
* @version UpLoadCheckPoint.java, v 1.1 2022/2/9 22:52 chenmin Exp $
|
||||
* Created on 2022/2/9
|
||||
*/
|
||||
@Data
|
||||
public class UpLoadCheckPoint implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 5424904565837227164L;
|
||||
|
||||
public static final String UPLOAD_MAGIC = "FE8BB4EA-B593-4FAC-AD7A-2459A36E2E62";
|
||||
|
||||
private String magic;
|
||||
private int md5;
|
||||
private String uploadFile;
|
||||
private UpLoadFileStat uploadFileStat;
|
||||
private String key;
|
||||
private String bucket;
|
||||
private String checkpointFile;
|
||||
private String uploadId;
|
||||
private List<UploadPart> uploadParts = Collections.synchronizedList(new ArrayList<>());
|
||||
private List<UpLoadPartEntityTag> partEntityTags = Collections.synchronizedList(new ArrayList<>());
|
||||
private long originPartSize;
|
||||
|
||||
/**
|
||||
* 从缓存文件中加载断点数据
|
||||
* @param checkpointFile 断点缓存文件
|
||||
*/
|
||||
public synchronized void load(String checkpointFile) {
|
||||
try {
|
||||
// TODO 缓存数据进行压缩
|
||||
UpLoadCheckPoint ucp = JSONUtil.readJSONObject(new File(checkpointFile), CharsetUtil.CHARSET_UTF_8).toBean(this.getClass());
|
||||
assign(ucp);
|
||||
} catch (Exception e) {
|
||||
throw new OssException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将断点信息写入到断点缓存文件
|
||||
*/
|
||||
public synchronized void dump() {
|
||||
this.setMd5(hashCode());
|
||||
try {
|
||||
FileUtil.writeUtf8String(JSONUtil.toJsonStr(this), checkpointFile);
|
||||
} catch (Exception e) {
|
||||
throw new OssException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新分块状态
|
||||
* @param partIndex 分片索引
|
||||
* @param partEntityTag 分片Tag
|
||||
* @param completed 分片是否完成
|
||||
*/
|
||||
public synchronized void update(int partIndex, UpLoadPartEntityTag partEntityTag, boolean completed) {
|
||||
this.getPartEntityTags().add(partEntityTag);
|
||||
this.getUploadParts().get(partIndex).setCompleted(completed);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查断点缓存文件是否与断点一致
|
||||
* @return 校验是否通过
|
||||
*/
|
||||
public synchronized boolean isValid() {
|
||||
// 比较checkpoint的magic和md5
|
||||
if (this.getMagic() == null || !this.getMagic().equals(UPLOAD_MAGIC) || this.getMd5() != hashCode()) {
|
||||
return false;
|
||||
}
|
||||
// 检查断点缓存文件是否存在
|
||||
if (!FileUtil.exist(checkpointFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
File file = new File(uploadFile);
|
||||
// 文件名,大小和上次修改时间必须与当前断点相同。
|
||||
// 如果有任何改变,则重新上传
|
||||
return this.getUploadFileStat().getSize() == file.length()
|
||||
&& this.getUploadFileStat().getLastModified() == file.lastModified();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((key == null) ? 0 : key.hashCode());
|
||||
result = prime * result + ((bucket == null) ? 0 : bucket.hashCode());
|
||||
result = prime * result + ((checkpointFile == null) ? 0 : checkpointFile.hashCode());
|
||||
result = prime * result + ((magic == null) ? 0 : magic.hashCode());
|
||||
result = prime * result + ((partEntityTags == null) ? 0 : partEntityTags.hashCode());
|
||||
result = prime * result + ((uploadFile == null) ? 0 : uploadFile.hashCode());
|
||||
result = prime * result + ((uploadFileStat == null) ? 0 : uploadFileStat.hashCode());
|
||||
result = prime * result + ((uploadId == null) ? 0 : uploadId.hashCode());
|
||||
result = prime * result + ((uploadParts == null) ? 0 : uploadParts.hashCode());
|
||||
result = prime * result + (int) originPartSize;
|
||||
return result;
|
||||
}
|
||||
|
||||
public void assign(UpLoadCheckPoint ucp) {
|
||||
this.setMagic(ucp.magic);
|
||||
this.setMd5(ucp.md5);
|
||||
this.setUploadFile(ucp.uploadFile);
|
||||
this.setUploadFileStat(ucp.uploadFileStat);
|
||||
this.setKey(ucp.key);
|
||||
this.setBucket(ucp.bucket);
|
||||
this.setCheckpointFile(ucp.checkpointFile);
|
||||
this.setUploadId(ucp.uploadId);
|
||||
this.setUploadParts(ucp.uploadParts);
|
||||
this.setPartEntityTags(ucp.partEntityTags);
|
||||
this.setOriginPartSize(ucp.originPartSize);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
package com.schisandra.oss.application.oss.model.upload;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 文件状态
|
||||
* @author landaiqing
|
||||
* @version FileStat.java, v 1.1 2022/2/9 22:54 chenmin Exp $
|
||||
* Created on 2022/2/9
|
||||
*/
|
||||
@Data
|
||||
public class UpLoadFileStat implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1223810339796425415L;
|
||||
|
||||
/**
|
||||
* 文件大小
|
||||
*/
|
||||
private long size;
|
||||
/**
|
||||
* 文件最新修改时间
|
||||
*/
|
||||
private long lastModified;
|
||||
/**
|
||||
* 文件内容签名
|
||||
*/
|
||||
private String digest;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((digest == null) ? 0 : digest.hashCode());
|
||||
result = prime * result + (int) (lastModified ^ (lastModified >>> 32));
|
||||
result = prime * result + (int) (size ^ (size >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
public static UpLoadFileStat getFileStat(String uploadFile) {
|
||||
UpLoadFileStat fileStat = new UpLoadFileStat();
|
||||
File file = new File(uploadFile);
|
||||
fileStat.setSize(file.length());
|
||||
fileStat.setLastModified(file.lastModified());
|
||||
return fileStat;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
package com.schisandra.oss.application.oss.model.upload;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 分块标签
|
||||
* @author landaiqing
|
||||
* @version PartETag.java, v 1.1 2022/2/10 23:38 chenmin Exp $
|
||||
* Created on 2022/2/10
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UpLoadPartEntityTag implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2471854027355307627L;
|
||||
|
||||
/**
|
||||
* 分块号
|
||||
*/
|
||||
private int partNumber;
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
private String eTag;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((this.eTag == null) ? 0 : this.eTag.hashCode());
|
||||
result = prime * result + this.partNumber;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (this.getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
UpLoadPartEntityTag other = (UpLoadPartEntityTag) obj;
|
||||
if (this.eTag == null) {
|
||||
if (other.eTag != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this.eTag.equals(other.eTag)) {
|
||||
return false;
|
||||
}
|
||||
if (this.partNumber != other.partNumber) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PartETag [partNumber=" + this.partNumber + ", eTag=" + this.eTag + "]";
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
package com.schisandra.oss.application.oss.model.upload;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 分块结果集
|
||||
* @author landaiqing
|
||||
* @version PartResult.java, v 1.1 2022/2/10 10:01 chenmin Exp $
|
||||
* Created on 2022/2/10
|
||||
*/
|
||||
@Accessors(chain = true)
|
||||
@Data
|
||||
public class UpLoadPartResult {
|
||||
|
||||
/**
|
||||
* 分块号
|
||||
*/
|
||||
private int number;
|
||||
/**
|
||||
* 分块在文件中的偏移量
|
||||
*/
|
||||
private long offset;
|
||||
/**
|
||||
* 分块大小
|
||||
*/
|
||||
private long length;
|
||||
/**
|
||||
* 分块失败标识
|
||||
*/
|
||||
private boolean failed = false;
|
||||
/**
|
||||
* 分块上传失败异常
|
||||
*/
|
||||
private Exception exception;
|
||||
/**
|
||||
* 分块crc
|
||||
*/
|
||||
private Long partCrc;
|
||||
|
||||
private UpLoadPartEntityTag entityTag;
|
||||
|
||||
public UpLoadPartResult(int number, long offset, long length) {
|
||||
this.number = number;
|
||||
this.offset = offset;
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public UpLoadPartResult(int number, long offset, long length, long partCrc) {
|
||||
this.number = number;
|
||||
this.offset = offset;
|
||||
this.length = length;
|
||||
this.partCrc = partCrc;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
package com.schisandra.oss.application.oss.model.upload;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 分块
|
||||
* @author landaiqing
|
||||
* @version UploadPart.java, v 1.1 2022/2/9 23:01 chenmin Exp $
|
||||
* Created on 2022/2/9
|
||||
*/
|
||||
@Data
|
||||
public class UploadPart implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6692863980224332199L;
|
||||
|
||||
/**
|
||||
* 分块号(顺序)
|
||||
*/
|
||||
private int number;
|
||||
/**
|
||||
* 分块在文件中的偏移量
|
||||
*/
|
||||
private long offset;
|
||||
/**
|
||||
* 分块大小
|
||||
*/
|
||||
private long size;
|
||||
/**
|
||||
* 分块成功标识
|
||||
*/
|
||||
private boolean isCompleted = false;
|
||||
/**
|
||||
* 分块crc
|
||||
*/
|
||||
private long crc;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (isCompleted ? 1231 : 1237);
|
||||
result = prime * result + number;
|
||||
result = prime * result + (int) (offset ^ (offset >>> 32));
|
||||
result = prime * result + (int) (size ^ (size >>> 32));
|
||||
result = prime * result + (int) (crc ^ (crc >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -119,5 +119,11 @@
|
||||
<version>0.4.8</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.14.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@@ -0,0 +1,270 @@
|
||||
package com.schisandra.oss.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* bo
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 20:10:20
|
||||
*/
|
||||
@Data
|
||||
public class SchisandraOssAliBO implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* OSS地址
|
||||
*/
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
* AccessKey ID
|
||||
*/
|
||||
private String accessKeyId;
|
||||
|
||||
/**
|
||||
* AccessKey Secret
|
||||
*/
|
||||
private String accessKeySecret;
|
||||
|
||||
/**
|
||||
* security Token
|
||||
*/
|
||||
private String securityToken;
|
||||
|
||||
/**
|
||||
* Bucket名称
|
||||
*/
|
||||
private String bucketName;
|
||||
|
||||
/**
|
||||
* 数据存储路径
|
||||
*/
|
||||
private String basePath;
|
||||
|
||||
/**
|
||||
* 用户代理,指HTTP的User-Agent头。默认为aliyun-sdk-java。
|
||||
*/
|
||||
private String userAgent;
|
||||
|
||||
/**
|
||||
* 请求失败后最大的重试次数。默认3次。
|
||||
*/
|
||||
private String maxErrorRetry;
|
||||
|
||||
/**
|
||||
* 从连接池中获取连接的超时时间(单位:毫秒)。默认不超时。
|
||||
*/
|
||||
private Integer connectionRequestTimeout;
|
||||
|
||||
/**
|
||||
* 建立连接的超时时间(单位:毫秒)。默认为50000毫秒。
|
||||
*/
|
||||
private Integer connectionTimeout;
|
||||
|
||||
/**
|
||||
* Socket层传输数据的超时时间(单位:毫秒)。默认为50000毫秒。
|
||||
*/
|
||||
private Integer socketTimeout;
|
||||
|
||||
/**
|
||||
* 允许打开的最大HTTP连接数。默认为1024
|
||||
*/
|
||||
private Integer maxConnections;
|
||||
|
||||
/**
|
||||
* 连接TTL (生存时间)。Http连接由连接管理器用TTL缓存。
|
||||
*/
|
||||
private Long connectionTTL;
|
||||
|
||||
/**
|
||||
* 是否使用com.aliyun.oss.common.comm.IdleConnectionReaper管理过期连接,默认开启
|
||||
*/
|
||||
private String useReaper;
|
||||
|
||||
/**
|
||||
* 连接空闲超时时间,超时则关闭连接(单位:毫秒)。默认为60000毫秒。
|
||||
*/
|
||||
private Long idleConnectionTime;
|
||||
|
||||
/**
|
||||
* 连接OSS所采用的协议(HTTP或HTTPS),默认为HTTP。
|
||||
*/
|
||||
private String protocol;
|
||||
|
||||
/**
|
||||
* 代理服务器主机地址。
|
||||
*/
|
||||
private String proxyHost;
|
||||
|
||||
/**
|
||||
* 代理服务器端口。
|
||||
*/
|
||||
private String proxyPort;
|
||||
|
||||
/**
|
||||
* 代理服务器验证的用户名。
|
||||
*/
|
||||
private String proxyUsername;
|
||||
|
||||
/**
|
||||
* 代理服务器验证的密码。
|
||||
*/
|
||||
private String proxyPassword;
|
||||
|
||||
/**
|
||||
* 代理服务器的域,该域可以执行NTLM认证
|
||||
*/
|
||||
private String proxyDomain;
|
||||
|
||||
/**
|
||||
* 代理主机的NTLM身份验证服务器
|
||||
*/
|
||||
private String proxyWorkstation;
|
||||
|
||||
/**
|
||||
* 是否支持CNAME作为Endpoint,默认支持CNAME。
|
||||
*/
|
||||
private String supportCname;
|
||||
|
||||
/**
|
||||
* 设置不可变排除的CName列表 ---- 任何以该列表中的项目结尾的域都不会进行Cname解析。
|
||||
*/
|
||||
private String cnameExcludeList;
|
||||
|
||||
/**
|
||||
* 是否开启二级域名(Second Level Domain)的访问方式,默认不开启。
|
||||
*/
|
||||
private String sldEnabled;
|
||||
|
||||
/**
|
||||
* 请求超时时间,单位:毫秒。默认情况下是5分钟。
|
||||
*/
|
||||
private Integer requestTimeout;
|
||||
|
||||
/**
|
||||
* 是否启用请求超时校验。默认情况下,它是禁用的。
|
||||
*/
|
||||
private String requestTimeoutEnabled;
|
||||
|
||||
/**
|
||||
* 设置慢请求的延迟阈值。如果请求的延迟大于延迟,则将记录该请求。默认情况下,阈值为5分钟。
|
||||
*/
|
||||
private Long slowRequestsThreshold;
|
||||
|
||||
/**
|
||||
* 设置默认的http头。所有请求头将自动添加到每个请求中。如果在请求中也指定了相同的请求头,则默认的标头将被覆盖。
|
||||
*/
|
||||
private String defaultHeaders;
|
||||
|
||||
/**
|
||||
* 是否在上传和下载时启用CRC校验,默认启用
|
||||
*/
|
||||
private String crcCheckEnabled;
|
||||
|
||||
/**
|
||||
* 所有请求设置签名版本
|
||||
*/
|
||||
private String signatureVersion;
|
||||
|
||||
/**
|
||||
* 设置OSS服务端时间和本地时间之间的差异,以毫秒为单位。
|
||||
*/
|
||||
private Long tickOffset;
|
||||
|
||||
/**
|
||||
* 是否开启HTTP重定向。
|
||||
说明: Java SDK 3.10.1及以上版本支持设置是否开启HTTP重定向,默认开启。
|
||||
*/
|
||||
private String redirectEnable;
|
||||
|
||||
/**
|
||||
* 是否开启SSL证书校验。
|
||||
* 说明: Java SDK 3.10.1及以上版本支持设置是否开启SSL证书校验,默认开启。
|
||||
*/
|
||||
private String verifySSLEnable;
|
||||
|
||||
/**
|
||||
* 是否开启日志记录连接池统计信息
|
||||
*/
|
||||
private String logConnectionPoolStats;
|
||||
|
||||
/**
|
||||
* 是否使用系统属性值
|
||||
*/
|
||||
private String useSystemPropertyValues;
|
||||
|
||||
/**
|
||||
* 分片大小,默认5MB
|
||||
*/
|
||||
private Integer partSize;
|
||||
|
||||
/**
|
||||
* 并发线程数,默认等于CPU的核数
|
||||
*/
|
||||
private Integer taskNum;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 是否开启高级设置
|
||||
*/
|
||||
private String openAdvancedSetup;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 是否删除 0 未删除 1已删除
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 额外字段
|
||||
*/
|
||||
private String extraJson;
|
||||
|
||||
/**
|
||||
* 当桶不存在,是否创建
|
||||
*/
|
||||
private String createBucket;
|
||||
|
||||
/**
|
||||
* 启动检测桶,是否存在
|
||||
*/
|
||||
private String checkBucket;
|
||||
|
||||
}
|
||||
|
@@ -1,163 +0,0 @@
|
||||
package com.schisandra.oss.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* bo
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-11 22:58:14
|
||||
*/
|
||||
@Data
|
||||
public class SchisandraOssConfigBO implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String ossType;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String accessKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String bucketName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String basePath;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String region;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer taskNum;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String partSize;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Double imgSize;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Double fileSize;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer connectTimeout;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer writeTimeout;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer readTimeout;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String zone;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String publicKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String privateKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String customHost;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String port;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String user;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String charset;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String extraJson;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createDate;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateDate;
|
||||
|
||||
/**
|
||||
* 是否删除 0未删除 1已删除
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,183 @@
|
||||
package com.schisandra.oss.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* bo
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 19:32:24
|
||||
*/
|
||||
@Data
|
||||
public class SchisandraOssMinioBO implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String accessKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String bucketName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer port;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String basePath;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String fileHost;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String downloadHost;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String uploadHost;
|
||||
|
||||
/**
|
||||
* 当桶不存在,是否创建
|
||||
*/
|
||||
private String createBucket;
|
||||
|
||||
/**
|
||||
* 启动检测桶,是否存在
|
||||
*/
|
||||
private String checkBucket;
|
||||
|
||||
/**
|
||||
* 连接超时时间(单位:毫秒)
|
||||
*/
|
||||
private Long connectTimeout;
|
||||
|
||||
/**
|
||||
* 写超时时间(单位:毫秒)
|
||||
*/
|
||||
private Long writeTimeout;
|
||||
|
||||
/**
|
||||
* 读超时时间(单位:毫秒)
|
||||
*/
|
||||
private Long readTimeout;
|
||||
|
||||
/**
|
||||
* 调用超时时间(单位:毫秒)
|
||||
*/
|
||||
private Long callTimeout;
|
||||
|
||||
/**
|
||||
* 是否支持重定向,默认支持
|
||||
*/
|
||||
private String followRedirects;
|
||||
|
||||
/**
|
||||
* 是否支持HTTP到HTTPS,HTTPS到HTTP的重定向,默认支持
|
||||
*/
|
||||
private String followSslRedirects;
|
||||
|
||||
/**
|
||||
* 是否开始连接失败重试,默认不支持
|
||||
*/
|
||||
private String retryOnConnectionFailure;
|
||||
|
||||
/**
|
||||
* 连接健康检测间隔时长(单位:毫秒)
|
||||
*/
|
||||
private Integer pingInterval;
|
||||
|
||||
/**
|
||||
* 分片大小,默认5MB
|
||||
*/
|
||||
private Long partSize;
|
||||
|
||||
/**
|
||||
* 并发线程数,默认等于CPU的核数
|
||||
*/
|
||||
private Integer taskNum;
|
||||
|
||||
/**
|
||||
* 图片大小限制,单位:m
|
||||
*/
|
||||
private Integer imgSize;
|
||||
|
||||
/**
|
||||
* 文件大小限制,单位:m
|
||||
*/
|
||||
private Integer fileSize;
|
||||
|
||||
/**
|
||||
* 额外json
|
||||
*/
|
||||
private String extraJson;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 是否删除 0 未删除 1已删除
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 是否开启高级设置
|
||||
*/
|
||||
private String openAdvancedSetup;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,23 @@
|
||||
package com.schisandra.oss.domain.convert;
|
||||
|
||||
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssAli;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* bo转换器
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 20:45:32
|
||||
*/
|
||||
@Mapper
|
||||
public interface SchisandraOssAliBOConverter {
|
||||
|
||||
SchisandraOssAliBOConverter INSTANCE = Mappers.getMapper(SchisandraOssAliBOConverter.class);
|
||||
|
||||
SchisandraOssAli convertBOToEntity(SchisandraOssAliBO schisandraOssAliBO);
|
||||
SchisandraOssAliBO convertEntityToBO(SchisandraOssAli schisandraOssAli);
|
||||
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
package com.schisandra.oss.domain.convert;
|
||||
|
||||
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssConfigBO;
|
||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssConfig;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* bo转换器
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-11 22:58:14
|
||||
*/
|
||||
@Mapper
|
||||
public interface SchisandraOssConfigBOConverter {
|
||||
|
||||
SchisandraOssConfigBOConverter INSTANCE = Mappers.getMapper(SchisandraOssConfigBOConverter.class);
|
||||
|
||||
SchisandraOssConfig convertBOToEntity(SchisandraOssConfigBO schisandraOssConfigBO);
|
||||
SchisandraOssConfigBO convertEntityToBO(SchisandraOssConfig schisandraOssConfig);
|
||||
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
package com.schisandra.oss.domain.convert;
|
||||
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssMinioBO;
|
||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssMinio;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* bo转换器
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 19:47:04
|
||||
*/
|
||||
@Mapper
|
||||
public interface SchisandraOssMinioBOConverter {
|
||||
|
||||
SchisandraOssMinioBOConverter INSTANCE = Mappers.getMapper(SchisandraOssMinioBOConverter.class);
|
||||
|
||||
SchisandraOssMinio convertBOToEntity(SchisandraOssMinioBO schisandraOssMinioBO);
|
||||
SchisandraOssMinioBO convertEntityToBO(SchisandraOssMinio schisandraOssMinio);
|
||||
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
package com.schisandra.oss.domain.service;
|
||||
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 领域service
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 20:45:32
|
||||
*/
|
||||
public interface SchisandraOssAliDomainService {
|
||||
|
||||
/**
|
||||
* 添加 信息
|
||||
*/
|
||||
Boolean add(SchisandraOssAliBO schisandraOssAliBO);
|
||||
|
||||
/**
|
||||
* 更新 信息
|
||||
*/
|
||||
Boolean update(SchisandraOssAliBO schisandraOssAliBO);
|
||||
|
||||
/**
|
||||
* 删除 信息
|
||||
*/
|
||||
Boolean delete(SchisandraOssAliBO schisandraOssAliBO);
|
||||
|
||||
SchisandraOssAliBO getAliOssConfig(Long userId);
|
||||
}
|
@@ -1,29 +0,0 @@
|
||||
package com.schisandra.oss.domain.service;
|
||||
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssConfigBO;
|
||||
|
||||
/**
|
||||
* 领域service
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-11 22:58:14
|
||||
*/
|
||||
public interface SchisandraOssConfigDomainService {
|
||||
|
||||
/**
|
||||
* 添加 信息
|
||||
*/
|
||||
Boolean add(SchisandraOssConfigBO schisandraOssConfigBO);
|
||||
|
||||
/**
|
||||
* 更新 信息
|
||||
*/
|
||||
Boolean update(SchisandraOssConfigBO schisandraOssConfigBO);
|
||||
|
||||
/**
|
||||
* 删除 信息
|
||||
*/
|
||||
Boolean delete(SchisandraOssConfigBO schisandraOssConfigBO);
|
||||
|
||||
SchisandraOssConfigBO getOssConfig(String minio);
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
package com.schisandra.oss.domain.service;
|
||||
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssMinioBO;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 领域service
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 19:47:04
|
||||
*/
|
||||
public interface SchisandraOssMinioDomainService {
|
||||
|
||||
/**
|
||||
* 添加 信息
|
||||
*/
|
||||
Boolean add(SchisandraOssMinioBO schisandraOssMinioBO);
|
||||
|
||||
/**
|
||||
* 更新 信息
|
||||
*/
|
||||
Boolean update(SchisandraOssMinioBO schisandraOssMinioBO);
|
||||
|
||||
/**
|
||||
* 删除 信息
|
||||
*/
|
||||
Boolean delete(SchisandraOssMinioBO schisandraOssMinioBO);
|
||||
|
||||
SchisandraOssMinioBO getMinioConfig(Long userId);
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
package com.schisandra.oss.domain.service.impl;
|
||||
|
||||
|
||||
import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||
import com.schisandra.oss.domain.convert.SchisandraOssAliBOConverter;
|
||||
import com.schisandra.oss.domain.service.SchisandraOssAliDomainService;
|
||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssAli;
|
||||
import com.schisandra.oss.infra.basic.service.SchisandraOssAliService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 领域service实现了
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 20:45:32
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SchisandraOssAliDomainServiceImpl implements SchisandraOssAliDomainService {
|
||||
|
||||
@Resource
|
||||
private SchisandraOssAliService schisandraOssAliService;
|
||||
|
||||
@Override
|
||||
public Boolean add(SchisandraOssAliBO schisandraOssAliBO) {
|
||||
SchisandraOssAli schisandraOssAli = SchisandraOssAliBOConverter.INSTANCE.convertBOToEntity(schisandraOssAliBO);
|
||||
schisandraOssAli.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
return schisandraOssAliService.insert(schisandraOssAli) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(SchisandraOssAliBO schisandraOssAliBO) {
|
||||
SchisandraOssAli schisandraOssAli = SchisandraOssAliBOConverter.INSTANCE.convertBOToEntity(schisandraOssAliBO);
|
||||
return schisandraOssAliService.update(schisandraOssAli) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean delete(SchisandraOssAliBO schisandraOssAliBO) {
|
||||
SchisandraOssAli schisandraOssAli = new SchisandraOssAli();
|
||||
schisandraOssAli.setId(schisandraOssAliBO.getId());
|
||||
schisandraOssAli.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
|
||||
return schisandraOssAliService.update(schisandraOssAli) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchisandraOssAliBO getAliOssConfig(Long userId) {
|
||||
SchisandraOssAli schisandraOssAli = schisandraOssAliService.getAliOssConfig(userId);
|
||||
SchisandraOssAliBO schisandraOssAliBO = SchisandraOssAliBOConverter.INSTANCE.convertEntityToBO(schisandraOssAli);
|
||||
return schisandraOssAliBO;
|
||||
}
|
||||
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
package com.schisandra.oss.domain.service.impl;
|
||||
|
||||
|
||||
import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
|
||||
import com.schisandra.oss.domain.convert.SchisandraOssConfigBOConverter;
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssConfigBO;
|
||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssConfig;
|
||||
import com.schisandra.oss.infra.basic.service.SchisandraOssConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 领域service实现了
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-11 22:58:14
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SchisandraOssConfigDomainService implements com.schisandra.oss.domain.service.SchisandraOssConfigDomainService {
|
||||
|
||||
@Resource
|
||||
private SchisandraOssConfigService schisandraOssConfigService;
|
||||
|
||||
@Override
|
||||
public Boolean add(SchisandraOssConfigBO schisandraOssConfigBO) {
|
||||
SchisandraOssConfig schisandraOssConfig = SchisandraOssConfigBOConverter.INSTANCE.convertBOToEntity(schisandraOssConfigBO);
|
||||
schisandraOssConfig.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
return schisandraOssConfigService.insert(schisandraOssConfig) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(SchisandraOssConfigBO schisandraOssConfigBO) {
|
||||
SchisandraOssConfig schisandraOssConfig = SchisandraOssConfigBOConverter.INSTANCE.convertBOToEntity(schisandraOssConfigBO);
|
||||
return schisandraOssConfigService.update(schisandraOssConfig) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean delete(SchisandraOssConfigBO schisandraOssConfigBO) {
|
||||
SchisandraOssConfig schisandraOssConfig = new SchisandraOssConfig();
|
||||
schisandraOssConfig.setId(schisandraOssConfigBO.getId());
|
||||
schisandraOssConfig.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
|
||||
return schisandraOssConfigService.update(schisandraOssConfig) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchisandraOssConfigBO getOssConfig(String ossType) {
|
||||
SchisandraOssConfig ossConfig = schisandraOssConfigService.getOssConfig(ossType);
|
||||
SchisandraOssConfigBO schisandraOssConfigBO = SchisandraOssConfigBOConverter.INSTANCE.convertEntityToBO(ossConfig);
|
||||
return schisandraOssConfigBO;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
package com.schisandra.oss.domain.service.impl;
|
||||
|
||||
|
||||
import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssMinioBO;
|
||||
import com.schisandra.oss.domain.convert.SchisandraOssMinioBOConverter;
|
||||
import com.schisandra.oss.domain.service.SchisandraOssMinioDomainService;
|
||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssMinio;
|
||||
import com.schisandra.oss.infra.basic.service.SchisandraOssMinioService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 领域service实现了
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 19:47:04
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SchisandraOssMinioDomainServiceImpl implements SchisandraOssMinioDomainService {
|
||||
|
||||
@Resource
|
||||
private SchisandraOssMinioService schisandraOssMinioService;
|
||||
|
||||
@Override
|
||||
public Boolean add(SchisandraOssMinioBO schisandraOssMinioBO) {
|
||||
SchisandraOssMinio schisandraOssMinio = SchisandraOssMinioBOConverter.INSTANCE.convertBOToEntity(schisandraOssMinioBO);
|
||||
schisandraOssMinio.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
return schisandraOssMinioService.insert(schisandraOssMinio) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(SchisandraOssMinioBO schisandraOssMinioBO) {
|
||||
SchisandraOssMinio schisandraOssMinio = SchisandraOssMinioBOConverter.INSTANCE.convertBOToEntity(schisandraOssMinioBO);
|
||||
return schisandraOssMinioService.update(schisandraOssMinio) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean delete(SchisandraOssMinioBO schisandraOssMinioBO) {
|
||||
SchisandraOssMinio schisandraOssMinio = new SchisandraOssMinio();
|
||||
schisandraOssMinio.setId(schisandraOssMinioBO.getId());
|
||||
schisandraOssMinio.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
|
||||
return schisandraOssMinioService.update(schisandraOssMinio) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchisandraOssMinioBO getMinioConfig(Long userId) {
|
||||
SchisandraOssMinio schisandraOssMinio= schisandraOssMinioService.getMinioConfig(userId);
|
||||
SchisandraOssMinioBO schisandraOssMinioBO = SchisandraOssMinioBOConverter.INSTANCE.convertEntityToBO(schisandraOssMinio);
|
||||
return schisandraOssMinioBO;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package com.schisandra.oss.infra.basic.dao;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssAli;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 表数据库访问层
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 20:10:20
|
||||
*/
|
||||
@Repository
|
||||
public interface SchisandraOssAliDao extends BaseMapper<SchisandraOssAli> {
|
||||
|
||||
}
|
||||
|
@@ -1,18 +0,0 @@
|
||||
package com.schisandra.oss.infra.basic.dao;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssConfig;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 表数据库访问层
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-11 22:58:14
|
||||
*/
|
||||
@Repository
|
||||
public interface SchisandraOssConfigDao extends BaseMapper<SchisandraOssConfig> {
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,18 @@
|
||||
package com.schisandra.oss.infra.basic.dao;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssMinio;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 表数据库访问层
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 19:32:24
|
||||
*/
|
||||
@Repository
|
||||
public interface SchisandraOssMinioDao extends BaseMapper<SchisandraOssMinio> {
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,325 @@
|
||||
package com.schisandra.oss.infra.basic.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 实体类
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 20:45:32
|
||||
*/
|
||||
@Data
|
||||
@TableName("schisandra_oss_ali")
|
||||
public class SchisandraOssAli implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(value = "`id`", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`user_id`")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* OSS地址
|
||||
*/
|
||||
@TableField("`endpoint`")
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
* AccessKey ID
|
||||
*/
|
||||
@TableField("`access_key_id`")
|
||||
private String accessKeyId;
|
||||
|
||||
/**
|
||||
* AccessKey Secret
|
||||
*/
|
||||
@TableField("`access_key_secret`")
|
||||
private String accessKeySecret;
|
||||
|
||||
/**
|
||||
* security Token
|
||||
*/
|
||||
@TableField("`security_token`")
|
||||
private String securityToken;
|
||||
|
||||
/**
|
||||
* Bucket名称
|
||||
*/
|
||||
@TableField("`bucket_name`")
|
||||
private String bucketName;
|
||||
|
||||
/**
|
||||
* 数据存储路径
|
||||
*/
|
||||
@TableField("`base_path`")
|
||||
private String basePath;
|
||||
|
||||
/**
|
||||
* 用户代理,指HTTP的User-Agent头。默认为aliyun-sdk-java。
|
||||
*/
|
||||
@TableField("`user_agent`")
|
||||
private String userAgent;
|
||||
|
||||
/**
|
||||
* 请求失败后最大的重试次数。默认3次。
|
||||
*/
|
||||
@TableField("`max_error_retry`")
|
||||
private String maxErrorRetry;
|
||||
|
||||
/**
|
||||
* 从连接池中获取连接的超时时间(单位:毫秒)。默认不超时。
|
||||
*/
|
||||
@TableField("`connection_request_timeout`")
|
||||
private Integer connectionRequestTimeout;
|
||||
|
||||
/**
|
||||
* 建立连接的超时时间(单位:毫秒)。默认为50000毫秒。
|
||||
*/
|
||||
@TableField("`connection_timeout`")
|
||||
private Integer connectionTimeout;
|
||||
|
||||
/**
|
||||
* Socket层传输数据的超时时间(单位:毫秒)。默认为50000毫秒。
|
||||
*/
|
||||
@TableField("`socket_timeout`")
|
||||
private Integer socketTimeout;
|
||||
|
||||
/**
|
||||
* 允许打开的最大HTTP连接数。默认为1024
|
||||
*/
|
||||
@TableField("`max_connections`")
|
||||
private Integer maxConnections;
|
||||
|
||||
/**
|
||||
* 连接TTL (生存时间)。Http连接由连接管理器用TTL缓存。
|
||||
*/
|
||||
@TableField("`connection_TTL`")
|
||||
private Long connectionTTL;
|
||||
|
||||
/**
|
||||
* 是否使用com.aliyun.oss.common.comm.IdleConnectionReaper管理过期连接,默认开启
|
||||
*/
|
||||
@TableField("`use_reaper`")
|
||||
private String useReaper;
|
||||
|
||||
/**
|
||||
* 连接空闲超时时间,超时则关闭连接(单位:毫秒)。默认为60000毫秒。
|
||||
*/
|
||||
@TableField("`idle_connection_time`")
|
||||
private Long idleConnectionTime;
|
||||
|
||||
/**
|
||||
* 连接OSS所采用的协议(HTTP或HTTPS),默认为HTTP。
|
||||
*/
|
||||
@TableField("`protocol`")
|
||||
private String protocol;
|
||||
|
||||
/**
|
||||
* 代理服务器主机地址。
|
||||
*/
|
||||
@TableField("`proxy_host`")
|
||||
private String proxyHost;
|
||||
|
||||
/**
|
||||
* 代理服务器端口。
|
||||
*/
|
||||
@TableField("`proxy_port`")
|
||||
private String proxyPort;
|
||||
|
||||
/**
|
||||
* 代理服务器验证的用户名。
|
||||
*/
|
||||
@TableField("`proxy_username`")
|
||||
private String proxyUsername;
|
||||
|
||||
/**
|
||||
* 代理服务器验证的密码。
|
||||
*/
|
||||
@TableField("`proxy_password`")
|
||||
private String proxyPassword;
|
||||
|
||||
/**
|
||||
* 代理服务器的域,该域可以执行NTLM认证
|
||||
*/
|
||||
@TableField("`proxy_domain`")
|
||||
private String proxyDomain;
|
||||
|
||||
/**
|
||||
* 代理主机的NTLM身份验证服务器
|
||||
*/
|
||||
@TableField("`proxy_workstation`")
|
||||
private String proxyWorkstation;
|
||||
|
||||
/**
|
||||
* 是否支持CNAME作为Endpoint,默认支持CNAME。
|
||||
*/
|
||||
@TableField("`support_cname`")
|
||||
private String supportCname;
|
||||
|
||||
/**
|
||||
* 设置不可变排除的CName列表 ---- 任何以该列表中的项目结尾的域都不会进行Cname解析。
|
||||
*/
|
||||
@TableField("`cname_exclude_list`")
|
||||
private String cnameExcludeList;
|
||||
|
||||
/**
|
||||
* 是否开启二级域名(Second Level Domain)的访问方式,默认不开启。
|
||||
*/
|
||||
@TableField("`sld_enabled`")
|
||||
private String sldEnabled;
|
||||
|
||||
/**
|
||||
* 请求超时时间,单位:毫秒。默认情况下是5分钟。
|
||||
*/
|
||||
@TableField("`request_timeout`")
|
||||
private Integer requestTimeout;
|
||||
|
||||
/**
|
||||
* 是否启用请求超时校验。默认情况下,它是禁用的。
|
||||
*/
|
||||
@TableField("`request_timeout_enabled`")
|
||||
private String requestTimeoutEnabled;
|
||||
|
||||
/**
|
||||
* 设置慢请求的延迟阈值。如果请求的延迟大于延迟,则将记录该请求。默认情况下,阈值为5分钟。
|
||||
*/
|
||||
@TableField("`slow_requests_threshold`")
|
||||
private Long slowRequestsThreshold;
|
||||
|
||||
/**
|
||||
* 设置默认的http头。所有请求头将自动添加到每个请求中。如果在请求中也指定了相同的请求头,则默认的标头将被覆盖。
|
||||
*/
|
||||
@TableField("`default_headers`")
|
||||
private String defaultHeaders;
|
||||
|
||||
/**
|
||||
* 是否在上传和下载时启用CRC校验,默认启用
|
||||
*/
|
||||
@TableField("`crc_check_enabled`")
|
||||
private String crcCheckEnabled;
|
||||
|
||||
/**
|
||||
* 所有请求设置签名版本
|
||||
*/
|
||||
@TableField("`signature_version`")
|
||||
private String signatureVersion;
|
||||
|
||||
/**
|
||||
* 设置OSS服务端时间和本地时间之间的差异,以毫秒为单位。
|
||||
*/
|
||||
@TableField("`tick_offset`")
|
||||
private Long tickOffset;
|
||||
|
||||
/**
|
||||
* 是否开启HTTP重定向。
|
||||
说明: Java SDK 3.10.1及以上版本支持设置是否开启HTTP重定向,默认开启。
|
||||
*/
|
||||
@TableField("`redirect_enable`")
|
||||
private String redirectEnable;
|
||||
|
||||
/**
|
||||
* 是否开启SSL证书校验。
|
||||
* 说明: Java SDK 3.10.1及以上版本支持设置是否开启SSL证书校验,默认开启。
|
||||
*/
|
||||
@TableField("`verify_SSL_enable`")
|
||||
private String verifySSLEnable;
|
||||
|
||||
/**
|
||||
* 是否开启日志记录连接池统计信息
|
||||
*/
|
||||
@TableField("`log_connection_pool_stats`")
|
||||
private String logConnectionPoolStats;
|
||||
|
||||
/**
|
||||
* 是否使用系统属性值
|
||||
*/
|
||||
@TableField("`use_system_property_values`")
|
||||
private String useSystemPropertyValues;
|
||||
|
||||
/**
|
||||
* 分片大小,默认5MB
|
||||
*/
|
||||
@TableField("`part_size`")
|
||||
private Integer partSize;
|
||||
|
||||
/**
|
||||
* 并发线程数,默认等于CPU的核数
|
||||
*/
|
||||
@TableField("`task_num`")
|
||||
private Integer taskNum;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@TableField("`status`")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 是否开启高级设置
|
||||
*/
|
||||
@TableField("`open_advanced_setup`")
|
||||
private String openAdvancedSetup;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField("`created_by`")
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("`created_time`")
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("`update_time`")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@TableField("`update_by`")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 是否删除 0 未删除 1已删除
|
||||
*/
|
||||
@TableField("`is_deleted`")
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 额外字段
|
||||
*/
|
||||
@TableField("`extra_json`")
|
||||
private String extraJson;
|
||||
|
||||
/**
|
||||
* 当桶不存在,是否创建
|
||||
*/
|
||||
@TableField("`create_bucket`")
|
||||
private String createBucket;
|
||||
|
||||
/**
|
||||
* 启动检测桶,是否存在
|
||||
*/
|
||||
@TableField("`check_bucket`")
|
||||
private String checkBucket;
|
||||
|
||||
}
|
||||
|
@@ -1,197 +0,0 @@
|
||||
package com.schisandra.oss.infra.basic.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 实体类
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-11 22:58:14
|
||||
*/
|
||||
@Data
|
||||
@TableName("schisandra_oss_config")
|
||||
public class SchisandraOssConfig implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(value = "`id`", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`oss_type`")
|
||||
private String ossType;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`endpoint`")
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`access_key`")
|
||||
private String accessKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`secret_key`")
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`bucket_name`")
|
||||
private String bucketName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`base_path`")
|
||||
private String basePath;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`region`")
|
||||
private String region;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`task_num`")
|
||||
private Integer taskNum;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`part_size`")
|
||||
private String partSize;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`img_size`")
|
||||
private Double imgSize;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`file_size`")
|
||||
private Double fileSize;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`connect_timeout`")
|
||||
private Integer connectTimeout;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`write_timeout`")
|
||||
private Integer writeTimeout;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`read_timeout`")
|
||||
private Integer readTimeout;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`zone`")
|
||||
private String zone;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`public_key`")
|
||||
private String publicKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`private_key`")
|
||||
private String privateKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`custom_host`")
|
||||
private String customHost;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`host`")
|
||||
private String host;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`port`")
|
||||
private String port;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`user`")
|
||||
private String user;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`password`")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`charset`")
|
||||
private String charset;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`extra_json`")
|
||||
private String extraJson;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("`create_date`")
|
||||
private Date createDate;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@TableField("`update_by`")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("`update_date`")
|
||||
private Date updateDate;
|
||||
|
||||
/**
|
||||
* 是否删除 0未删除 1已删除
|
||||
*/
|
||||
@TableField("`is_deleted`")
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,221 @@
|
||||
package com.schisandra.oss.infra.basic.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 实体类
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 19:47:04
|
||||
*/
|
||||
@Data
|
||||
@TableName("schisandra_oss_minio")
|
||||
public class SchisandraOssMinio implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(value = "`id`", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`user_id`")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`endpoint`")
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`accessKey`")
|
||||
private String accessKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`secretKey`")
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`bucketName`")
|
||||
private String bucketName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`port`")
|
||||
private Integer port;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`basePath`")
|
||||
private String basePath;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`file_host`")
|
||||
private String fileHost;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`download_host`")
|
||||
private String downloadHost;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("`upload_host`")
|
||||
private String uploadHost;
|
||||
|
||||
/**
|
||||
* 当桶不存在,是否创建
|
||||
*/
|
||||
@TableField("`create_bucket`")
|
||||
private String createBucket;
|
||||
|
||||
/**
|
||||
* 启动检测桶,是否存在
|
||||
*/
|
||||
@TableField("`check_bucket`")
|
||||
private String checkBucket;
|
||||
|
||||
/**
|
||||
* 连接超时时间(单位:毫秒)
|
||||
*/
|
||||
@TableField("`connect_timeout`")
|
||||
private Long connectTimeout;
|
||||
|
||||
/**
|
||||
* 写超时时间(单位:毫秒)
|
||||
*/
|
||||
@TableField("`write_timeout`")
|
||||
private Long writeTimeout;
|
||||
|
||||
/**
|
||||
* 读超时时间(单位:毫秒)
|
||||
*/
|
||||
@TableField("`read_timeout`")
|
||||
private Long readTimeout;
|
||||
|
||||
/**
|
||||
* 调用超时时间(单位:毫秒)
|
||||
*/
|
||||
@TableField("`call_timeout`")
|
||||
private Long callTimeout;
|
||||
|
||||
/**
|
||||
* 是否支持重定向,默认支持
|
||||
*/
|
||||
@TableField("`follow_redirects`")
|
||||
private String followRedirects;
|
||||
|
||||
/**
|
||||
* 是否支持HTTP到HTTPS,HTTPS到HTTP的重定向,默认支持
|
||||
*/
|
||||
@TableField("`follow_ssl_redirects`")
|
||||
private String followSslRedirects;
|
||||
|
||||
/**
|
||||
* 是否开始连接失败重试,默认不支持
|
||||
*/
|
||||
@TableField("`retry_on_connection_failure`")
|
||||
private String retryOnConnectionFailure;
|
||||
|
||||
/**
|
||||
* 连接健康检测间隔时长(单位:毫秒)
|
||||
*/
|
||||
@TableField("`ping_interval`")
|
||||
private Integer pingInterval;
|
||||
|
||||
/**
|
||||
* 分片大小,默认5MB
|
||||
*/
|
||||
@TableField("`part_size`")
|
||||
private Long partSize;
|
||||
|
||||
/**
|
||||
* 并发线程数,默认等于CPU的核数
|
||||
*/
|
||||
@TableField("`task_num`")
|
||||
private Integer taskNum;
|
||||
|
||||
/**
|
||||
* 图片大小限制,单位:m
|
||||
*/
|
||||
@TableField("`img_size`")
|
||||
private Integer imgSize;
|
||||
|
||||
/**
|
||||
* 文件大小限制,单位:m
|
||||
*/
|
||||
@TableField("`file_size`")
|
||||
private Integer fileSize;
|
||||
|
||||
/**
|
||||
* 额外json
|
||||
*/
|
||||
@TableField("`extra_json`")
|
||||
private String extraJson;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@TableField("`status`")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField("`created_by`")
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("`created_time`")
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("`update_time`")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@TableField("`update_by`")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 是否删除 0 未删除 1已删除
|
||||
*/
|
||||
@TableField("`is_deleted`")
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 是否开启高级设置
|
||||
*/
|
||||
@TableField("`open_advanced_setup`")
|
||||
private String openAdvancedSetup;
|
||||
|
||||
}
|
||||
|
@@ -1,14 +1,15 @@
|
||||
package com.schisandra.oss.infra.basic.service;
|
||||
|
||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssConfig;
|
||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssAli;
|
||||
|
||||
|
||||
/**
|
||||
* 表服务接口
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-11 22:58:14
|
||||
* @since 2024-05-14 20:45:32
|
||||
*/
|
||||
public interface SchisandraOssConfigService {
|
||||
public interface SchisandraOssAliService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
@@ -16,23 +17,23 @@ public interface SchisandraOssConfigService {
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
SchisandraOssConfig queryById(Long id);
|
||||
SchisandraOssAli queryById(Long id);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param schisandraOssConfig 实例对象
|
||||
* @param schisandraOssAli 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int insert(SchisandraOssConfig schisandraOssConfig);
|
||||
int insert(SchisandraOssAli schisandraOssAli);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param schisandraOssConfig 实例对象
|
||||
* @param schisandraOssAli 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int update(SchisandraOssConfig schisandraOssConfig);
|
||||
int update(SchisandraOssAli schisandraOssAli);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
@@ -45,7 +46,7 @@ public interface SchisandraOssConfigService {
|
||||
/**
|
||||
* 根据条件查询角色
|
||||
*/
|
||||
SchisandraOssConfig queryByCondition(SchisandraOssConfig schisandraOssConfig);
|
||||
SchisandraOssAli queryByCondition(SchisandraOssAli schisandraOssAli);
|
||||
|
||||
SchisandraOssConfig getOssConfig(String ossType);
|
||||
SchisandraOssAli getAliOssConfig(Long userId);
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
package com.schisandra.oss.infra.basic.service;
|
||||
|
||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssMinio;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 表服务接口
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 19:47:04
|
||||
*/
|
||||
public interface SchisandraOssMinioService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
SchisandraOssMinio queryById(Long id);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param schisandraOssMinio 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int insert(SchisandraOssMinio schisandraOssMinio);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param schisandraOssMinio 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int update(SchisandraOssMinio schisandraOssMinio);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
/**
|
||||
* 根据条件查询角色
|
||||
*/
|
||||
SchisandraOssMinio queryByCondition(SchisandraOssMinio schisandraOssMinio);
|
||||
|
||||
SchisandraOssMinio getMinioConfig(Long userId);
|
||||
}
|
@@ -0,0 +1,141 @@
|
||||
package com.schisandra.oss.infra.basic.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.schisandra.oss.infra.basic.dao.SchisandraOssAliDao;
|
||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssAli;
|
||||
import com.schisandra.oss.infra.basic.service.SchisandraOssAliService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 表服务实现类
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 20:45:32
|
||||
*/
|
||||
@Service("SchisandraOssAliService")
|
||||
public class SchisandraOssAliServiceImpl implements SchisandraOssAliService {
|
||||
|
||||
@Resource
|
||||
private SchisandraOssAliDao schisandraOssAliDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SchisandraOssAli queryById(Long id) {
|
||||
return this.schisandraOssAliDao.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param schisandraOssAli 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int insert(SchisandraOssAli schisandraOssAli) {
|
||||
return this.schisandraOssAliDao.insert(schisandraOssAli);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param schisandraOssAli 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int update(SchisandraOssAli schisandraOssAli) {
|
||||
return this.schisandraOssAliDao.updateById(schisandraOssAli);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.schisandraOssAliDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
*
|
||||
* @param schisandraOssAli 条件
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SchisandraOssAli queryByCondition(SchisandraOssAli schisandraOssAli) {
|
||||
|
||||
LambdaQueryWrapper<SchisandraOssAli> queryWrapper = Wrappers.<SchisandraOssAli>lambdaQuery()
|
||||
.eq(Objects.nonNull(schisandraOssAli.getId()), SchisandraOssAli::getId, schisandraOssAli.getId())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getUserId()), SchisandraOssAli::getUserId, schisandraOssAli.getUserId())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getEndpoint()), SchisandraOssAli::getEndpoint, schisandraOssAli.getEndpoint())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getAccessKeyId()), SchisandraOssAli::getAccessKeyId, schisandraOssAli.getAccessKeyId())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getAccessKeySecret()), SchisandraOssAli::getAccessKeySecret, schisandraOssAli.getAccessKeySecret())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getSecurityToken()), SchisandraOssAli::getSecurityToken, schisandraOssAli.getSecurityToken())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getBucketName()), SchisandraOssAli::getBucketName, schisandraOssAli.getBucketName())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getBasePath()), SchisandraOssAli::getBasePath, schisandraOssAli.getBasePath())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getUserAgent()), SchisandraOssAli::getUserAgent, schisandraOssAli.getUserAgent())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getMaxErrorRetry()), SchisandraOssAli::getMaxErrorRetry, schisandraOssAli.getMaxErrorRetry())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getConnectionRequestTimeout()), SchisandraOssAli::getConnectionRequestTimeout, schisandraOssAli.getConnectionRequestTimeout())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getConnectionTimeout()), SchisandraOssAli::getConnectionTimeout, schisandraOssAli.getConnectionTimeout())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getSocketTimeout()), SchisandraOssAli::getSocketTimeout, schisandraOssAli.getSocketTimeout())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getMaxConnections()), SchisandraOssAli::getMaxConnections, schisandraOssAli.getMaxConnections())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getConnectionTTL()), SchisandraOssAli::getConnectionTTL, schisandraOssAli.getConnectionTTL())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getUseReaper()), SchisandraOssAli::getUseReaper, schisandraOssAli.getUseReaper())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getIdleConnectionTime()), SchisandraOssAli::getIdleConnectionTime, schisandraOssAli.getIdleConnectionTime())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getProtocol()), SchisandraOssAli::getProtocol, schisandraOssAli.getProtocol())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getProxyHost()), SchisandraOssAli::getProxyHost, schisandraOssAli.getProxyHost())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getProxyPort()), SchisandraOssAli::getProxyPort, schisandraOssAli.getProxyPort())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getProxyUsername()), SchisandraOssAli::getProxyUsername, schisandraOssAli.getProxyUsername())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getProxyPassword()), SchisandraOssAli::getProxyPassword, schisandraOssAli.getProxyPassword())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getProxyDomain()), SchisandraOssAli::getProxyDomain, schisandraOssAli.getProxyDomain())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getProxyWorkstation()), SchisandraOssAli::getProxyWorkstation, schisandraOssAli.getProxyWorkstation())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getSupportCname()), SchisandraOssAli::getSupportCname, schisandraOssAli.getSupportCname())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getCnameExcludeList()), SchisandraOssAli::getCnameExcludeList, schisandraOssAli.getCnameExcludeList())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getSldEnabled()), SchisandraOssAli::getSldEnabled, schisandraOssAli.getSldEnabled())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getRequestTimeout()), SchisandraOssAli::getRequestTimeout, schisandraOssAli.getRequestTimeout())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getRequestTimeoutEnabled()), SchisandraOssAli::getRequestTimeoutEnabled, schisandraOssAli.getRequestTimeoutEnabled())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getSlowRequestsThreshold()), SchisandraOssAli::getSlowRequestsThreshold, schisandraOssAli.getSlowRequestsThreshold())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getDefaultHeaders()), SchisandraOssAli::getDefaultHeaders, schisandraOssAli.getDefaultHeaders())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getCrcCheckEnabled()), SchisandraOssAli::getCrcCheckEnabled, schisandraOssAli.getCrcCheckEnabled())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getSignatureVersion()), SchisandraOssAli::getSignatureVersion, schisandraOssAli.getSignatureVersion())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getTickOffset()), SchisandraOssAli::getTickOffset, schisandraOssAli.getTickOffset())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getRedirectEnable()), SchisandraOssAli::getRedirectEnable, schisandraOssAli.getRedirectEnable())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getVerifySSLEnable()), SchisandraOssAli::getVerifySSLEnable, schisandraOssAli.getVerifySSLEnable())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getLogConnectionPoolStats()), SchisandraOssAli::getLogConnectionPoolStats, schisandraOssAli.getLogConnectionPoolStats())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getUseSystemPropertyValues()), SchisandraOssAli::getUseSystemPropertyValues, schisandraOssAli.getUseSystemPropertyValues())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getPartSize()), SchisandraOssAli::getPartSize, schisandraOssAli.getPartSize())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getTaskNum()), SchisandraOssAli::getTaskNum, schisandraOssAli.getTaskNum())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getStatus()), SchisandraOssAli::getStatus, schisandraOssAli.getStatus())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getOpenAdvancedSetup()), SchisandraOssAli::getOpenAdvancedSetup, schisandraOssAli.getOpenAdvancedSetup())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getCreatedBy()), SchisandraOssAli::getCreatedBy, schisandraOssAli.getCreatedBy())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getCreatedTime()), SchisandraOssAli::getCreatedTime, schisandraOssAli.getCreatedTime())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getUpdateTime()), SchisandraOssAli::getUpdateTime, schisandraOssAli.getUpdateTime())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getUpdateBy()), SchisandraOssAli::getUpdateBy, schisandraOssAli.getUpdateBy())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getIsDeleted()), SchisandraOssAli::getIsDeleted, schisandraOssAli.getIsDeleted())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getExtraJson()), SchisandraOssAli::getExtraJson, schisandraOssAli.getExtraJson())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getCreateBucket()), SchisandraOssAli::getCreateBucket, schisandraOssAli.getCreateBucket())
|
||||
.eq(Objects.nonNull(schisandraOssAli.getCheckBucket()), SchisandraOssAli::getCheckBucket, schisandraOssAli.getCheckBucket());
|
||||
return schisandraOssAliDao.selectOne(queryWrapper);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchisandraOssAli getAliOssConfig(Long userId) {
|
||||
return schisandraOssAliDao.selectOne(new QueryWrapper<SchisandraOssAli>()
|
||||
.eq("user_id", userId)
|
||||
.eq("is_deleted", 0));
|
||||
}
|
||||
|
||||
}
|
@@ -1,122 +0,0 @@
|
||||
package com.schisandra.oss.infra.basic.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.schisandra.oss.infra.basic.dao.SchisandraOssConfigDao;
|
||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssConfig;
|
||||
import com.schisandra.oss.infra.basic.service.SchisandraOssConfigService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 表服务实现类
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-11 22:58:14
|
||||
*/
|
||||
@Service("SchisandraOssConfigService")
|
||||
public class SchisandraOssConfigServiceImpl implements SchisandraOssConfigService {
|
||||
|
||||
@Resource
|
||||
private SchisandraOssConfigDao schisandraOssConfigDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SchisandraOssConfig queryById(Long id) {
|
||||
return this.schisandraOssConfigDao.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param schisandraOssConfig 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int insert(SchisandraOssConfig schisandraOssConfig) {
|
||||
return this.schisandraOssConfigDao.insert(schisandraOssConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param schisandraOssConfig 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int update(SchisandraOssConfig schisandraOssConfig) {
|
||||
return this.schisandraOssConfigDao.updateById(schisandraOssConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.schisandraOssConfigDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
*
|
||||
* @param schisandraOssConfig 条件
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SchisandraOssConfig queryByCondition(SchisandraOssConfig schisandraOssConfig) {
|
||||
|
||||
LambdaQueryWrapper<SchisandraOssConfig> queryWrapper = Wrappers.<SchisandraOssConfig>lambdaQuery()
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getId()), SchisandraOssConfig::getId, schisandraOssConfig.getId())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getOssType()), SchisandraOssConfig::getOssType, schisandraOssConfig.getOssType())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getEndpoint()), SchisandraOssConfig::getEndpoint, schisandraOssConfig.getEndpoint())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getAccessKey()), SchisandraOssConfig::getAccessKey, schisandraOssConfig.getAccessKey())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getSecretKey()), SchisandraOssConfig::getSecretKey, schisandraOssConfig.getSecretKey())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getBucketName()), SchisandraOssConfig::getBucketName, schisandraOssConfig.getBucketName())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getBasePath()), SchisandraOssConfig::getBasePath, schisandraOssConfig.getBasePath())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getRegion()), SchisandraOssConfig::getRegion, schisandraOssConfig.getRegion())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getTaskNum()), SchisandraOssConfig::getTaskNum, schisandraOssConfig.getTaskNum())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getPartSize()), SchisandraOssConfig::getPartSize, schisandraOssConfig.getPartSize())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getImgSize()), SchisandraOssConfig::getImgSize, schisandraOssConfig.getImgSize())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getFileSize()), SchisandraOssConfig::getFileSize, schisandraOssConfig.getFileSize())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getConnectTimeout()), SchisandraOssConfig::getConnectTimeout, schisandraOssConfig.getConnectTimeout())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getWriteTimeout()), SchisandraOssConfig::getWriteTimeout, schisandraOssConfig.getWriteTimeout())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getReadTimeout()), SchisandraOssConfig::getReadTimeout, schisandraOssConfig.getReadTimeout())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getZone()), SchisandraOssConfig::getZone, schisandraOssConfig.getZone())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getPublicKey()), SchisandraOssConfig::getPublicKey, schisandraOssConfig.getPublicKey())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getPrivateKey()), SchisandraOssConfig::getPrivateKey, schisandraOssConfig.getPrivateKey())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getCustomHost()), SchisandraOssConfig::getCustomHost, schisandraOssConfig.getCustomHost())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getHost()), SchisandraOssConfig::getHost, schisandraOssConfig.getHost())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getPort()), SchisandraOssConfig::getPort, schisandraOssConfig.getPort())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getUser()), SchisandraOssConfig::getUser, schisandraOssConfig.getUser())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getPassword()), SchisandraOssConfig::getPassword, schisandraOssConfig.getPassword())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getCharset()), SchisandraOssConfig::getCharset, schisandraOssConfig.getCharset())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getExtraJson()), SchisandraOssConfig::getExtraJson, schisandraOssConfig.getExtraJson())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getCreateDate()), SchisandraOssConfig::getCreateDate, schisandraOssConfig.getCreateDate())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getUpdateBy()), SchisandraOssConfig::getUpdateBy, schisandraOssConfig.getUpdateBy())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getUpdateDate()), SchisandraOssConfig::getUpdateDate, schisandraOssConfig.getUpdateDate())
|
||||
.eq(Objects.nonNull(schisandraOssConfig.getIsDeleted()), SchisandraOssConfig::getIsDeleted, schisandraOssConfig.getIsDeleted())
|
||||
;
|
||||
return schisandraOssConfigDao.selectOne(queryWrapper);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchisandraOssConfig getOssConfig(String ossType) {
|
||||
SchisandraOssConfig ossConfig = schisandraOssConfigDao.selectOne(new QueryWrapper<SchisandraOssConfig>()
|
||||
.eq("oss_type", ossType).eq("is_deleted", 0));
|
||||
return ossConfig;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,126 @@
|
||||
package com.schisandra.oss.infra.basic.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
|
||||
import com.schisandra.oss.infra.basic.dao.SchisandraOssMinioDao;
|
||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssMinio;
|
||||
import com.schisandra.oss.infra.basic.service.SchisandraOssMinioService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 表服务实现类
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-14 19:47:04
|
||||
*/
|
||||
@Service("SchisandraOssMinioService")
|
||||
public class SchisandraOssMinioServiceImpl implements SchisandraOssMinioService {
|
||||
|
||||
@Resource
|
||||
private SchisandraOssMinioDao schisandraOssMinioDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SchisandraOssMinio queryById(Long id) {
|
||||
return this.schisandraOssMinioDao.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param schisandraOssMinio 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int insert(SchisandraOssMinio schisandraOssMinio) {
|
||||
return this.schisandraOssMinioDao.insert(schisandraOssMinio);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param schisandraOssMinio 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int update(SchisandraOssMinio schisandraOssMinio) {
|
||||
return this.schisandraOssMinioDao.updateById(schisandraOssMinio);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.schisandraOssMinioDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
*
|
||||
* @param schisandraOssMinio 条件
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SchisandraOssMinio queryByCondition(SchisandraOssMinio schisandraOssMinio) {
|
||||
|
||||
LambdaQueryWrapper<SchisandraOssMinio> queryWrapper = Wrappers.<SchisandraOssMinio>lambdaQuery()
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getId()), SchisandraOssMinio::getId, schisandraOssMinio.getId())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getUserId()), SchisandraOssMinio::getUserId, schisandraOssMinio.getUserId())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getEndpoint()), SchisandraOssMinio::getEndpoint, schisandraOssMinio.getEndpoint())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getAccessKey()), SchisandraOssMinio::getAccessKey, schisandraOssMinio.getAccessKey())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getSecretKey()), SchisandraOssMinio::getSecretKey, schisandraOssMinio.getSecretKey())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getBucketName()), SchisandraOssMinio::getBucketName, schisandraOssMinio.getBucketName())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getPort()), SchisandraOssMinio::getPort, schisandraOssMinio.getPort())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getBasePath()), SchisandraOssMinio::getBasePath, schisandraOssMinio.getBasePath())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getFileHost()), SchisandraOssMinio::getFileHost, schisandraOssMinio.getFileHost())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getDownloadHost()), SchisandraOssMinio::getDownloadHost, schisandraOssMinio.getDownloadHost())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getUploadHost()), SchisandraOssMinio::getUploadHost, schisandraOssMinio.getUploadHost())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getCreateBucket()), SchisandraOssMinio::getCreateBucket, schisandraOssMinio.getCreateBucket())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getCheckBucket()), SchisandraOssMinio::getCheckBucket, schisandraOssMinio.getCheckBucket())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getConnectTimeout()), SchisandraOssMinio::getConnectTimeout, schisandraOssMinio.getConnectTimeout())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getWriteTimeout()), SchisandraOssMinio::getWriteTimeout, schisandraOssMinio.getWriteTimeout())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getReadTimeout()), SchisandraOssMinio::getReadTimeout, schisandraOssMinio.getReadTimeout())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getCallTimeout()), SchisandraOssMinio::getCallTimeout, schisandraOssMinio.getCallTimeout())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getFollowRedirects()), SchisandraOssMinio::getFollowRedirects, schisandraOssMinio.getFollowRedirects())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getFollowSslRedirects()), SchisandraOssMinio::getFollowSslRedirects, schisandraOssMinio.getFollowSslRedirects())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getRetryOnConnectionFailure()), SchisandraOssMinio::getRetryOnConnectionFailure, schisandraOssMinio.getRetryOnConnectionFailure())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getPingInterval()), SchisandraOssMinio::getPingInterval, schisandraOssMinio.getPingInterval())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getPartSize()), SchisandraOssMinio::getPartSize, schisandraOssMinio.getPartSize())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getTaskNum()), SchisandraOssMinio::getTaskNum, schisandraOssMinio.getTaskNum())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getImgSize()), SchisandraOssMinio::getImgSize, schisandraOssMinio.getImgSize())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getFileSize()), SchisandraOssMinio::getFileSize, schisandraOssMinio.getFileSize())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getExtraJson()), SchisandraOssMinio::getExtraJson, schisandraOssMinio.getExtraJson())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getStatus()), SchisandraOssMinio::getStatus, schisandraOssMinio.getStatus())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getCreatedBy()), SchisandraOssMinio::getCreatedBy, schisandraOssMinio.getCreatedBy())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getCreatedTime()), SchisandraOssMinio::getCreatedTime, schisandraOssMinio.getCreatedTime())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getUpdateTime()), SchisandraOssMinio::getUpdateTime, schisandraOssMinio.getUpdateTime())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getUpdateBy()), SchisandraOssMinio::getUpdateBy, schisandraOssMinio.getUpdateBy())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getIsDeleted()), SchisandraOssMinio::getIsDeleted, schisandraOssMinio.getIsDeleted())
|
||||
.eq(Objects.nonNull(schisandraOssMinio.getOpenAdvancedSetup()), SchisandraOssMinio::getOpenAdvancedSetup, schisandraOssMinio.getOpenAdvancedSetup());
|
||||
return schisandraOssMinioDao.selectOne(queryWrapper);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchisandraOssMinio getMinioConfig(Long userId) {
|
||||
return schisandraOssMinioDao.selectOne(new QueryWrapper<SchisandraOssMinio>
|
||||
()
|
||||
.eq("user_id", userId)
|
||||
.eq("is_deleted", 0));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.schisandra.oss.infra.basic.mapper.SchisandraOssAliDao">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.schisandra.oss.infra.basic.entity.SchisandraOssAli">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="user_id" jdbcType="BIGINT" property="userId"/>
|
||||
<result column="endpoint" jdbcType="VARCHAR" property="endpoint"/>
|
||||
<result column="access_key_id" jdbcType="VARCHAR" property="accessKeyId"/>
|
||||
<result column="access_key_secret" jdbcType="VARCHAR" property="accessKeySecret"/>
|
||||
<result column="security_token" jdbcType="VARCHAR" property="securityToken"/>
|
||||
<result column="bucket_name" jdbcType="VARCHAR" property="bucketName"/>
|
||||
<result column="base_path" jdbcType="VARCHAR" property="basePath"/>
|
||||
<result column="user_agent" jdbcType="VARCHAR" property="userAgent"/>
|
||||
<result column="max_error_retry" jdbcType="VARCHAR" property="maxErrorRetry"/>
|
||||
<result column="connection_request_timeout" jdbcType="INTEGER" property="connectionRequestTimeout"/>
|
||||
<result column="connection_timeout" jdbcType="INTEGER" property="connectionTimeout"/>
|
||||
<result column="socket_timeout" jdbcType="INTEGER" property="socketTimeout"/>
|
||||
<result column="max_connections" jdbcType="INTEGER" property="maxConnections"/>
|
||||
<result column="connection_TTL" jdbcType="BIGINT" property="connectionTTL"/>
|
||||
<result column="use_reaper" jdbcType="VARCHAR" property="useReaper"/>
|
||||
<result column="idle_connection_time" jdbcType="BIGINT" property="idleConnectionTime"/>
|
||||
<result column="protocol" jdbcType="VARCHAR" property="protocol"/>
|
||||
<result column="proxy_host" jdbcType="VARCHAR" property="proxyHost"/>
|
||||
<result column="proxy_port" jdbcType="VARCHAR" property="proxyPort"/>
|
||||
<result column="proxy_username" jdbcType="VARCHAR" property="proxyUsername"/>
|
||||
<result column="proxy_password" jdbcType="VARCHAR" property="proxyPassword"/>
|
||||
<result column="proxy_domain" jdbcType="VARCHAR" property="proxyDomain"/>
|
||||
<result column="proxy_workstation" jdbcType="VARCHAR" property="proxyWorkstation"/>
|
||||
<result column="support_cname" jdbcType="VARCHAR" property="supportCname"/>
|
||||
<result column="cname_exclude_list" jdbcType="VARCHAR" property="cnameExcludeList"/>
|
||||
<result column="sld_enabled" jdbcType="VARCHAR" property="sldEnabled"/>
|
||||
<result column="request_timeout" jdbcType="INTEGER" property="requestTimeout"/>
|
||||
<result column="request_timeout_enabled" jdbcType="VARCHAR" property="requestTimeoutEnabled"/>
|
||||
<result column="slow_requests_threshold" jdbcType="BIGINT" property="slowRequestsThreshold"/>
|
||||
<result column="default_headers" jdbcType="VARCHAR" property="defaultHeaders"/>
|
||||
<result column="crc_check_enabled" jdbcType="VARCHAR" property="crcCheckEnabled"/>
|
||||
<result column="signature_version" jdbcType="VARCHAR" property="signatureVersion"/>
|
||||
<result column="tick_offset" jdbcType="BIGINT" property="tickOffset"/>
|
||||
<result column="redirect_enable" jdbcType="VARCHAR" property="redirectEnable"/>
|
||||
<result column="verify_SSL_enable" jdbcType="VARCHAR" property="verifySSLEnable"/>
|
||||
<result column="log_connection_pool_stats" jdbcType="VARCHAR" property="logConnectionPoolStats"/>
|
||||
<result column="use_system_property_values" jdbcType="VARCHAR" property="useSystemPropertyValues"/>
|
||||
<result column="part_size" jdbcType="INTEGER" property="partSize"/>
|
||||
<result column="task_num" jdbcType="INTEGER" property="taskNum"/>
|
||||
<result column="status" jdbcType="VARCHAR" property="status"/>
|
||||
<result column="open_advanced_setup" jdbcType="VARCHAR" property="openAdvancedSetup"/>
|
||||
<result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
|
||||
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
|
||||
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
|
||||
<result column="extra_json" jdbcType="VARCHAR" property="extraJson"/>
|
||||
<result column="create_bucket" jdbcType="VARCHAR" property="createBucket"/>
|
||||
<result column="check_bucket" jdbcType="VARCHAR" property="checkBucket"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
@@ -1,37 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.schisandra.oss.infra.basic.mapper.SchisandraOssConfigDao">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.schisandra.oss.infra.basic.entity.SchisandraOssConfig">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="oss_type" jdbcType="VARCHAR" property="ossType"/>
|
||||
<result column="endpoint" jdbcType="VARCHAR" property="endpoint"/>
|
||||
<result column="access_key" jdbcType="VARCHAR" property="accessKey"/>
|
||||
<result column="secret_key" jdbcType="VARCHAR" property="secretKey"/>
|
||||
<result column="bucket_name" jdbcType="VARCHAR" property="bucketName"/>
|
||||
<result column="base_path" jdbcType="VARCHAR" property="basePath"/>
|
||||
<result column="region" jdbcType="VARCHAR" property="region"/>
|
||||
<result column="task_num" jdbcType="INTEGER" property="taskNum"/>
|
||||
<result column="part_size" jdbcType="VARCHAR" property="partSize"/>
|
||||
<result column="img_size" jdbcType="DOUBLE" property="imgSize"/>
|
||||
<result column="file_size" jdbcType="DOUBLE" property="fileSize"/>
|
||||
<result column="connect_timeout" jdbcType="INTEGER" property="connectTimeout"/>
|
||||
<result column="write_timeout" jdbcType="INTEGER" property="writeTimeout"/>
|
||||
<result column="read_timeout" jdbcType="INTEGER" property="readTimeout"/>
|
||||
<result column="zone" jdbcType="VARCHAR" property="zone"/>
|
||||
<result column="public_key" jdbcType="VARCHAR" property="publicKey"/>
|
||||
<result column="private_key" jdbcType="VARCHAR" property="privateKey"/>
|
||||
<result column="custom_host" jdbcType="VARCHAR" property="customHost"/>
|
||||
<result column="host" jdbcType="VARCHAR" property="host"/>
|
||||
<result column="port" jdbcType="VARCHAR" property="port"/>
|
||||
<result column="user" jdbcType="VARCHAR" property="user"/>
|
||||
<result column="password" jdbcType="VARCHAR" property="password"/>
|
||||
<result column="charset" jdbcType="VARCHAR" property="charset"/>
|
||||
<result column="extra_json" jdbcType="VARCHAR" property="extraJson"/>
|
||||
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
|
||||
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
|
||||
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
|
||||
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.schisandra.oss.infra.basic.mapper.SchisandraOssMinioDao">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.schisandra.oss.infra.basic.entity.SchisandraOssMinio">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="user_id" jdbcType="BIGINT" property="userId"/>
|
||||
<result column="endpoint" jdbcType="VARCHAR" property="endpoint"/>
|
||||
<result column="accessKey" jdbcType="VARCHAR" property="accessKey"/>
|
||||
<result column="secretKey" jdbcType="VARCHAR" property="secretKey"/>
|
||||
<result column="bucketName" jdbcType="VARCHAR" property="bucketName"/>
|
||||
<result column="port" jdbcType="INTEGER" property="port"/>
|
||||
<result column="basePath" jdbcType="VARCHAR" property="basePath"/>
|
||||
<result column="file_host" jdbcType="VARCHAR" property="fileHost"/>
|
||||
<result column="download_host" jdbcType="VARCHAR" property="downloadHost"/>
|
||||
<result column="upload_host" jdbcType="VARCHAR" property="uploadHost"/>
|
||||
<result column="create_bucket" jdbcType="VARCHAR" property="createBucket"/>
|
||||
<result column="check_bucket" jdbcType="VARCHAR" property="checkBucket"/>
|
||||
<result column="connect_timeout" jdbcType="BIGINT" property="connectTimeout"/>
|
||||
<result column="write_timeout" jdbcType="BIGINT" property="writeTimeout"/>
|
||||
<result column="read_timeout" jdbcType="BIGINT" property="readTimeout"/>
|
||||
<result column="call_timeout" jdbcType="BIGINT" property="callTimeout"/>
|
||||
<result column="follow_redirects" jdbcType="VARCHAR" property="followRedirects"/>
|
||||
<result column="follow_ssl_redirects" jdbcType="VARCHAR" property="followSslRedirects"/>
|
||||
<result column="retry_on_connection_failure" jdbcType="VARCHAR" property="retryOnConnectionFailure"/>
|
||||
<result column="ping_interval" jdbcType="INTEGER" property="pingInterval"/>
|
||||
<result column="part_size" jdbcType="BIGINT" property="partSize"/>
|
||||
<result column="task_num" jdbcType="INTEGER" property="taskNum"/>
|
||||
<result column="img_size" jdbcType="INTEGER" property="imgSize"/>
|
||||
<result column="file_size" jdbcType="INTEGER" property="fileSize"/>
|
||||
<result column="extra_json" jdbcType="VARCHAR" property="extraJson"/>
|
||||
<result column="status" jdbcType="VARCHAR" property="status"/>
|
||||
<result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
|
||||
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
|
||||
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
|
||||
<result column="open_advanced_setup" jdbcType="VARCHAR" property="openAdvancedSetup"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user