feat: update

This commit is contained in:
landaiqing
2024-07-23 22:54:22 +08:00
parent e3eb62c660
commit 14010b5161
5 changed files with 124 additions and 120 deletions

View File

@@ -87,7 +87,6 @@ public interface SchisandraAuthUserDomainService {
* @author: landaiqing
* @date: 2024/5/26 17:27
*/
@Cacheable(value = "userInfo", key = "#userId")
SchisandraAuthUserBO queryById(String userId);
/**

View File

@@ -167,12 +167,12 @@ public class SchisandraOssMinioController {
Preconditions.checkNotNull(userId, "不能为空");
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
bean.getMinioOssConfig().setBucketName(bucket);
List<OssInfo> object = (List<OssInfo>) caffeineUtil.caffeineBuild().getIfPresent(userId + bucket + dirName);
List<OssInfo> object = (List<OssInfo>) caffeineUtil.caffeineBuild().getIfPresent("MinioListDir" + userId + bucket + dirName);
if (object != null) {
return Result.ok(object);
} else {
List<OssInfo> list = bean.listDir(bucket, dirName);
caffeineUtil.caffeineBuild().put(userId + bucket + dirName, list);
caffeineUtil.caffeineBuild().put("MinioListDir" + userId + bucket + dirName, list);
return Result.ok(list);
}
@@ -235,7 +235,7 @@ public class SchisandraOssMinioController {
Preconditions.checkNotNull(userId, "不能为空");
Preconditions.checkNotNull(filePath, "不能为空");
int index = filePath.lastIndexOf("/");
String fileName = filePath.substring(index + 1);
String fileName = filePath.substring(0,index + 1);
caffeineUtil.caffeineBuild().invalidate("MinioListDir" + userId + bucket + fileName);
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
bean.getMinioOssConfig().setBucketName(bucket);
@@ -255,14 +255,15 @@ public class SchisandraOssMinioController {
String path = schisandraOssMinioDTO.getPath();
String bucket = schisandraOssMinioDTO.getBucketName();
String userId = schisandraOssMinioDTO.getUserId();
Preconditions.checkNotNull(path, "path不能为空");
Preconditions.checkNotNull(bucket, "bucket不能为空");
Preconditions.checkNotNull(userId, "userId不能为空");
if (path.lastIndexOf("") == path.length() - 1) {
path = path + file.getName();
} else {
if (path == null || "".equals(path)) {
path = "/";
}
if (path.lastIndexOf("/") < path.length() - 1) {
path = path + "/" + file.getOriginalFilename();
}
path=path+file.getOriginalFilename();
// 获取文件输入流
InputStream is = file.getInputStream();
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);

View File

@@ -1,60 +1,60 @@
package com.schisandra.oss.application.oss.constant;
import java.util.concurrent.TimeUnit;
/**
* @author landaiqing
*/
public class OssConstant {
public static final String OSS = "oss";
public static final String ENABLE = "enable";
public static final String DEFAULT_ENABLE_VALUE = "true";
public static final int KB = 1024;
public static final int MB = 1024 * KB;
/**
* 默认分片大小
*/
public static final Long DEFAULT_PART_SIZE = 5L * MB;
/**
* 默认缓冲区大小
*/
public static final int DEFAULT_BUFFER_SIZE = 8 * KB;
/**
* 默认最大分片数
*/
public static final Long DEFAULT_PART_NUM = 10000L;
/**
* 默认并发线程数
*/
public static final Integer DEFAULT_TASK_NUM = Runtime.getRuntime().availableProcessors();
public static final Long DEFAULT_CONNECTION_TIMEOUT = TimeUnit.MINUTES.toMillis(5);
/**
* OSS存储类型
*/
public interface OssType {
String LOCAL = "local";
String FTP = "ftp";
String SFTP = "sftp";
String ALI = "ali";
String QINIU = "qiniu";
String MINIO = "minio";
String BAIDU = "baidu";
String TENCENT = "tencent";
String HUAWEI = "huawei";
String JD = "jd";
String UP = "up";
String JINSHAN = "jinshan";
String WANGYI = "wangyi";
String UCLOUD = "ucloud";
String PINGAN = "pingan";
String QINGYUN = "qingyun";
String JDBC = "jdbc";
String AWS = "aws";
}
}
package com.schisandra.oss.application.oss.constant;
import java.util.concurrent.TimeUnit;
/**
* @author landaiqing
*/
public class OssConstant {
public static final String OSS = "oss";
public static final String ENABLE = "enable";
public static final String DEFAULT_ENABLE_VALUE = "true";
public static final int KB = 1024;
public static final int MB = 1024 * KB;
/**
* 默认分片大小
*/
public static final Long DEFAULT_PART_SIZE = 5L * MB;
/**
* 默认缓冲区大小
*/
public static final int DEFAULT_BUFFER_SIZE = 8 * KB;
/**
* 默认最大分片数
*/
public static final Long DEFAULT_PART_NUM = 10000L;
/**
* 默认并发线程数
*/
public static final Integer DEFAULT_TASK_NUM = Runtime.getRuntime().availableProcessors();
public static final Long DEFAULT_CONNECTION_TIMEOUT = TimeUnit.MINUTES.toMillis(10);
/**
* OSS存储类型
*/
public interface OssType {
String LOCAL = "local";
String FTP = "ftp";
String SFTP = "sftp";
String ALI = "ali";
String QINIU = "qiniu";
String MINIO = "minio";
String BAIDU = "baidu";
String TENCENT = "tencent";
String HUAWEI = "huawei";
String JD = "jd";
String UP = "up";
String JINSHAN = "jinshan";
String WANGYI = "wangyi";
String UCLOUD = "ucloud";
String PINGAN = "pingan";
String QINGYUN = "qingyun";
String JDBC = "jdbc";
String AWS = "aws";
}
}

View File

@@ -1,52 +1,52 @@
package com.schisandra.oss.application.oss.core.minio.model;
import com.schisandra.oss.application.oss.constant.OssConstant;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
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到HTTPSHTTPS到HTTP的重定向默认支持
*/
private boolean followSslRedirects = true;
/**
* 是否开始连接失败重试,默认不支持
*/
private boolean retryOnConnectionFailure = false;
/**
* 连接健康检测间隔时长(单位:毫秒)
*/
private int pingInterval;
}
package com.schisandra.oss.application.oss.core.minio.model;
import com.schisandra.oss.application.oss.constant.OssConstant;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
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到HTTPSHTTPS到HTTP的重定向默认支持
*/
private boolean followSslRedirects = true;
/**
* 是否开始连接失败重试,默认不支持
*/
private boolean retryOnConnectionFailure = true;
/**
* 连接健康检测间隔时长(单位:毫秒)
*/
private int pingInterval;
}

View File

@@ -1,6 +1,10 @@
server:
port: 4000
spring:
servlet:
multipart:
max-file-size: 100MB # 设置单个文件最大大小为10MB
max-request-size: 100MB # 设置多个文件大小为100MB
datasource:
username: root
password: BZbVbGDBePiA2q8/mt0eMxKNpHniDzxBtOxFadQiAOTDzCDlopC4qOKwwBEi9CAZcuFsCrRJdwn0wP6jwsnzxw==