mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	update 使用 策略+工厂 重写OSS模块
This commit is contained in:
		@@ -22,6 +22,10 @@
 | 
				
			|||||||
            <groupId>com.ruoyi</groupId>
 | 
					            <groupId>com.ruoyi</groupId>
 | 
				
			||||||
            <artifactId>ruoyi-common</artifactId>
 | 
					            <artifactId>ruoyi-common</artifactId>
 | 
				
			||||||
        </dependency>
 | 
					        </dependency>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>com.ruoyi</groupId>
 | 
				
			||||||
 | 
					            <artifactId>ruoyi-system</artifactId>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <dependency>
 | 
					        <dependency>
 | 
				
			||||||
            <groupId>com.qiniu</groupId>
 | 
					            <groupId>com.qiniu</groupId>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,69 +0,0 @@
 | 
				
			|||||||
package com.ruoyi.oss.config;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import lombok.Data;
 | 
					 | 
				
			||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
 | 
					 | 
				
			||||||
import org.springframework.context.annotation.Configuration;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.io.Serializable;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * 云存储配置信息
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
@Data
 | 
					 | 
				
			||||||
@Configuration
 | 
					 | 
				
			||||||
@ConfigurationProperties(prefix = "cloud-storage")
 | 
					 | 
				
			||||||
public class CloudStorageConfig implements Serializable {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	private static final long serialVersionUID = 1L;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 类型 1:七牛 2:阿里云 3:腾讯云 4: minio
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	private Integer type;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 七牛绑定的域名
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	private String domain;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 七牛路径前缀
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	private String prefix;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 七牛ACCESS_KEY
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	private String accessKey;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 七牛SECRET_KEY
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	private String secretKey;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 七牛存储空间名
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	private String bucketName;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 腾讯云AppId
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	private Integer qcloudAppId;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 腾讯云SecretId
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	private String qcloudSecretId;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 腾讯云SecretKey
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	private String qcloudSecretKey;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 腾讯云COS所属地区
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	private String qcloudRegion;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,43 +1,16 @@
 | 
				
			|||||||
package com.ruoyi.oss.constant;
 | 
					package com.ruoyi.oss.constant;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import lombok.AllArgsConstructor;
 | 
					/**
 | 
				
			||||||
import lombok.Getter;
 | 
					 * 云存储常量
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Lion Li
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class CloudConstant {
 | 
					public class CloudConstant {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * 云存储配置KEY
 | 
						 * 云存储配置KEY
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public final static String CLOUD_STORAGE_CONFIG_KEY = "sys.oss.cloud-storage";
 | 
						public final static String CLOUD_STORAGE_CONFIG_KEY = "sys.oss.cloudStorageService";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 云服务商
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	@Getter
 | 
					 | 
				
			||||||
	@AllArgsConstructor
 | 
					 | 
				
			||||||
	public enum CloudService {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/**
 | 
					 | 
				
			||||||
		 * 七牛云
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		QINIU(1),
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/**
 | 
					 | 
				
			||||||
		 * 阿里云
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		ALIYUN(2),
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/**
 | 
					 | 
				
			||||||
		 * 腾讯云
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		QCLOUD(3),
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/**
 | 
					 | 
				
			||||||
		 * minio
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		MINIO(4);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		private final int value;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,36 @@
 | 
				
			|||||||
 | 
					package com.ruoyi.oss.enumd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import lombok.AllArgsConstructor;
 | 
				
			||||||
 | 
					import lombok.Getter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 云存储服务商枚举
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author LionLi
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Getter
 | 
				
			||||||
 | 
					@AllArgsConstructor
 | 
				
			||||||
 | 
					public enum CloudServiceEnumd {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 七牛云
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						QINIU("qiniu"),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 阿里云
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						ALIYUN("aliyun"),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 腾讯云
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						QCLOUD("qcloud"),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * minio
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						MINIO("minio");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private final String value;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					package com.ruoyi.oss.factory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cn.hutool.core.lang.Assert;
 | 
				
			||||||
 | 
					import com.ruoyi.common.utils.spring.SpringUtils;
 | 
				
			||||||
 | 
					import com.ruoyi.oss.constant.CloudConstant;
 | 
				
			||||||
 | 
					import com.ruoyi.oss.service.ICloudStorageService;
 | 
				
			||||||
 | 
					import com.ruoyi.system.service.ISysConfigService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					import java.util.concurrent.ConcurrentHashMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 文件上传Factory
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Lion Li
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class OssFactory {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static ISysConfigService sysConfigService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						static {
 | 
				
			||||||
 | 
							OssFactory.sysConfigService = SpringUtils.getBean(ISysConfigService.class);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private static final Map<String, ICloudStorageService> SERVICES = new ConcurrentHashMap<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static ICloudStorageService instance() {
 | 
				
			||||||
 | 
							String type = sysConfigService.selectConfigByKey(CloudConstant.CLOUD_STORAGE_CONFIG_KEY);
 | 
				
			||||||
 | 
							return SERVICES.get(type);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static ICloudStorageService instance(String type) {
 | 
				
			||||||
 | 
							return SERVICES.get(type);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static void register(String type, ICloudStorageService iCloudStorageService) {
 | 
				
			||||||
 | 
							Assert.notNull(type, "type can't be null");
 | 
				
			||||||
 | 
							SERVICES.put(type, iCloudStorageService);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					package com.ruoyi.oss.properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import lombok.Data;
 | 
				
			||||||
 | 
					import lombok.NoArgsConstructor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 阿里云 配置属性
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Lion Li
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Data
 | 
				
			||||||
 | 
					@NoArgsConstructor
 | 
				
			||||||
 | 
					public class AliyunProperties {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 阿里云绑定的域名
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String endpoint;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 阿里云路径前缀
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String prefix;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 阿里云AccessKeyId
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String accessKeyId;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 阿里云AccessKeySecret
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String accessKeySecret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 阿里云BucketName
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String bucketName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					package com.ruoyi.oss.properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import lombok.Data;
 | 
				
			||||||
 | 
					import org.springframework.boot.context.properties.ConfigurationProperties;
 | 
				
			||||||
 | 
					import org.springframework.stereotype.Component;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * OSS云存储 配置属性
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Lion Li
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Data
 | 
				
			||||||
 | 
					@Component
 | 
				
			||||||
 | 
					@ConfigurationProperties(prefix = "cloud-storage")
 | 
				
			||||||
 | 
					public class CloudStorageProperties {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private QiniuProperties qiniu;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private AliyunProperties aliyun;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private QcloudProperties qcloud;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private MinioProperties minio;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					package com.ruoyi.oss.properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import lombok.Data;
 | 
				
			||||||
 | 
					import lombok.NoArgsConstructor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Minio 配置属性
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Lion Li
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Data
 | 
				
			||||||
 | 
					@NoArgsConstructor
 | 
				
			||||||
 | 
					public class MinioProperties {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 七牛绑定的域名
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String endpoint;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 七牛路径前缀
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String prefix;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 七牛ACCESS_KEY
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String accessKey;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 七牛SECRET_KEY
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String secretKey;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 七牛存储空间名
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String bucketName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,45 @@
 | 
				
			|||||||
 | 
					package com.ruoyi.oss.properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import lombok.Data;
 | 
				
			||||||
 | 
					import lombok.NoArgsConstructor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 腾讯云COS 配置属性
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Lion Li
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Data
 | 
				
			||||||
 | 
					@NoArgsConstructor
 | 
				
			||||||
 | 
					public class QcloudProperties {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 腾讯云绑定的域名
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String domain;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 腾讯云路径前缀
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String prefix;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 腾讯云SecretId
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String secretId;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 腾讯云SecretKey
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String secretKey;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 腾讯云BucketName
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String bucketName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 腾讯云COS所属地区
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String region;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					package com.ruoyi.oss.properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import lombok.Data;
 | 
				
			||||||
 | 
					import lombok.NoArgsConstructor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 七牛云 配置属性
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Lion Li
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Data
 | 
				
			||||||
 | 
					@NoArgsConstructor
 | 
				
			||||||
 | 
					public class QiniuProperties {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 七牛绑定的域名
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String domain;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 七牛路径前缀
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String prefix;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 七牛ACCESS_KEY
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String accessKey;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 七牛SECRET_KEY
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String secretKey;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 七牛存储空间名
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private String bucketName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -2,8 +2,18 @@ package com.ruoyi.oss.service;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import java.io.InputStream;
 | 
					import java.io.InputStream;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 云存储服务接口
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Lion Li
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public interface ICloudStorageService {
 | 
					public interface ICloudStorageService {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 获取服务商类型
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						String getServiceType();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * 文件路径
 | 
						 * 文件路径
 | 
				
			||||||
	 *
 | 
						 *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,36 +1,55 @@
 | 
				
			|||||||
package com.ruoyi.oss.service.abstractd;
 | 
					package com.ruoyi.oss.service.abstractd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cn.hutool.core.date.DateUtil;
 | 
				
			||||||
 | 
					import cn.hutool.core.io.IoUtil;
 | 
				
			||||||
 | 
					import cn.hutool.core.util.IdUtil;
 | 
				
			||||||
import cn.hutool.core.util.StrUtil;
 | 
					import cn.hutool.core.util.StrUtil;
 | 
				
			||||||
import com.ruoyi.oss.config.CloudStorageConfig;
 | 
					 | 
				
			||||||
import com.ruoyi.oss.service.ICloudStorageService;
 | 
					import com.ruoyi.oss.service.ICloudStorageService;
 | 
				
			||||||
import com.ruoyi.oss.utils.DateUtils;
 | 
					import org.springframework.beans.factory.InitializingBean;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.UUID;
 | 
					import java.io.InputStream;
 | 
				
			||||||
 | 
					import java.util.Date;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 云存储(支持七牛、阿里云、腾讯云、minio)
 | 
					 * 云存储(支持七牛、阿里云、腾讯云、minio)
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Lion Li
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public abstract class AbstractCloudStorageService implements ICloudStorageService {
 | 
					public abstract class AbstractCloudStorageService implements ICloudStorageService, InitializingBean {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						@Override
 | 
				
			||||||
	 * 云存储配置信息
 | 
						public abstract String getServiceType();
 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	protected CloudStorageConfig config;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public int getServiceType() {
 | 
					 | 
				
			||||||
		return config.getType();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public String getPath(String prefix, String suffix) {
 | 
						public String getPath(String prefix, String suffix) {
 | 
				
			||||||
		// 生成uuid
 | 
							// 生成uuid
 | 
				
			||||||
		String uuid = UUID.randomUUID().toString().replaceAll("-", "");
 | 
							String uuid = IdUtil.fastSimpleUUID();
 | 
				
			||||||
		// 文件路径
 | 
							// 文件路径
 | 
				
			||||||
		String path = DateUtils.dateTime() + "/" + uuid;
 | 
							String path = DateUtil.format(new Date(), "yyyyMMdd") + "/" + uuid;
 | 
				
			||||||
		if (StrUtil.isNotBlank(prefix)) {
 | 
							if (StrUtil.isNotBlank(prefix)) {
 | 
				
			||||||
			path = prefix + "/" + path;
 | 
								path = prefix + "/" + path;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return path + suffix;
 | 
							return path + suffix;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public abstract String upload(byte[] data, String path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public abstract void delete(String path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public String upload(InputStream inputStream, String path) {
 | 
				
			||||||
 | 
							byte[] data = IoUtil.readBytes(inputStream);
 | 
				
			||||||
 | 
							return this.upload(data, path);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public abstract String uploadSuffix(byte[] data, String suffix);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public abstract String uploadSuffix(InputStream inputStream, String suffix);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public abstract void afterPropertiesSet() throws Exception;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,28 +1,47 @@
 | 
				
			|||||||
package com.ruoyi.oss.service.impl;
 | 
					package com.ruoyi.oss.service.impl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.aliyun.oss.ClientConfiguration;
 | 
				
			||||||
import com.aliyun.oss.OSSClient;
 | 
					import com.aliyun.oss.OSSClient;
 | 
				
			||||||
import com.ruoyi.oss.config.CloudStorageConfig;
 | 
					import com.aliyun.oss.common.auth.DefaultCredentialProvider;
 | 
				
			||||||
 | 
					import com.ruoyi.oss.enumd.CloudServiceEnumd;
 | 
				
			||||||
import com.ruoyi.oss.exception.OssException;
 | 
					import com.ruoyi.oss.exception.OssException;
 | 
				
			||||||
 | 
					import com.ruoyi.oss.factory.OssFactory;
 | 
				
			||||||
 | 
					import com.ruoyi.oss.properties.AliyunProperties;
 | 
				
			||||||
 | 
					import com.ruoyi.oss.properties.CloudStorageProperties;
 | 
				
			||||||
import com.ruoyi.oss.service.abstractd.AbstractCloudStorageService;
 | 
					import com.ruoyi.oss.service.abstractd.AbstractCloudStorageService;
 | 
				
			||||||
 | 
					import org.springframework.beans.factory.InitializingBean;
 | 
				
			||||||
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
 | 
					import org.springframework.context.annotation.Lazy;
 | 
				
			||||||
 | 
					import org.springframework.stereotype.Service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.ByteArrayInputStream;
 | 
					import java.io.ByteArrayInputStream;
 | 
				
			||||||
import java.io.InputStream;
 | 
					import java.io.InputStream;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 阿里云存储
 | 
					 * 阿里云存储
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Lion Li
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class AliyunCloudStorageServiceImpl extends AbstractCloudStorageService {
 | 
					@Lazy
 | 
				
			||||||
 | 
					@Service
 | 
				
			||||||
 | 
					public class AliyunCloudStorageServiceImpl extends AbstractCloudStorageService implements InitializingBean {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private OSSClient client;
 | 
						private final OSSClient client;
 | 
				
			||||||
 | 
						private final AliyunProperties properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public AliyunCloudStorageServiceImpl(CloudStorageConfig config) {
 | 
						@Autowired
 | 
				
			||||||
		this.config = config;
 | 
						public AliyunCloudStorageServiceImpl(CloudStorageProperties properties) {
 | 
				
			||||||
		// 初始化
 | 
							this.properties = properties.getAliyun();
 | 
				
			||||||
		init();
 | 
							ClientConfiguration configuration = new ClientConfiguration();
 | 
				
			||||||
 | 
							DefaultCredentialProvider credentialProvider = new DefaultCredentialProvider(
 | 
				
			||||||
 | 
								this.properties.getAccessKeyId(),
 | 
				
			||||||
 | 
								this.properties.getAccessKeySecret());
 | 
				
			||||||
 | 
							client = new OSSClient(this.properties.getEndpoint(), credentialProvider, configuration);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private void init() {
 | 
						@Override
 | 
				
			||||||
		client = new OSSClient(config.getDomain(), config.getAccessKey(), config.getSecretKey());
 | 
						public String getServiceType() {
 | 
				
			||||||
 | 
							return CloudServiceEnumd.ALIYUN.getValue();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
@@ -33,18 +52,18 @@ public class AliyunCloudStorageServiceImpl extends AbstractCloudStorageService {
 | 
				
			|||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public String upload(InputStream inputStream, String path) {
 | 
						public String upload(InputStream inputStream, String path) {
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			client.putObject(config.getBucketName(), path, inputStream);
 | 
								client.putObject(this.properties.getBucketName(), path, inputStream);
 | 
				
			||||||
		} catch (Exception e) {
 | 
							} catch (Exception e) {
 | 
				
			||||||
			throw new OssException("上传文件失败,请检查配置信息");
 | 
								throw new OssException("上传文件失败,请检查配置信息");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return config.getDomain() + "/" + path;
 | 
							return this.properties.getEndpoint() + "/" + path;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void delete(String path) {
 | 
						public void delete(String path) {
 | 
				
			||||||
		path = path.replace(config.getDomain() + "/", "");
 | 
							path = path.replace(this.properties.getEndpoint() + "/", "");
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			client.deleteObject(config.getBucketName(), path);
 | 
								client.deleteObject(this.properties.getBucketName(), path);
 | 
				
			||||||
		} catch (Exception e) {
 | 
							} catch (Exception e) {
 | 
				
			||||||
			throw new OssException("上传文件失败,请检查配置信息");
 | 
								throw new OssException("上传文件失败,请检查配置信息");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -52,11 +71,16 @@ public class AliyunCloudStorageServiceImpl extends AbstractCloudStorageService {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public String uploadSuffix(byte[] data, String suffix) {
 | 
						public String uploadSuffix(byte[] data, String suffix) {
 | 
				
			||||||
		return upload(data, getPath(config.getPrefix(), suffix));
 | 
							return upload(data, getPath(this.properties.getPrefix(), suffix));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public String uploadSuffix(InputStream inputStream, String suffix) {
 | 
						public String uploadSuffix(InputStream inputStream, String suffix) {
 | 
				
			||||||
		return upload(inputStream, getPath(config.getPrefix(), suffix));
 | 
							return upload(inputStream, getPath(this.properties.getPrefix(), suffix));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void afterPropertiesSet() throws Exception {
 | 
				
			||||||
 | 
							OssFactory.register(getServiceType(),this);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,31 +1,43 @@
 | 
				
			|||||||
package com.ruoyi.oss.service.impl;
 | 
					package com.ruoyi.oss.service.impl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import cn.hutool.core.io.IoUtil;
 | 
					import com.ruoyi.oss.enumd.CloudServiceEnumd;
 | 
				
			||||||
import com.ruoyi.oss.config.CloudStorageConfig;
 | 
					 | 
				
			||||||
import com.ruoyi.oss.exception.OssException;
 | 
					import com.ruoyi.oss.exception.OssException;
 | 
				
			||||||
 | 
					import com.ruoyi.oss.factory.OssFactory;
 | 
				
			||||||
 | 
					import com.ruoyi.oss.properties.CloudStorageProperties;
 | 
				
			||||||
 | 
					import com.ruoyi.oss.properties.MinioProperties;
 | 
				
			||||||
import com.ruoyi.oss.service.abstractd.AbstractCloudStorageService;
 | 
					import com.ruoyi.oss.service.abstractd.AbstractCloudStorageService;
 | 
				
			||||||
import io.minio.MinioClient;
 | 
					import io.minio.MinioClient;
 | 
				
			||||||
 | 
					import org.springframework.beans.factory.InitializingBean;
 | 
				
			||||||
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
 | 
					import org.springframework.context.annotation.Lazy;
 | 
				
			||||||
 | 
					import org.springframework.stereotype.Service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.InputStream;
 | 
					import java.io.InputStream;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * minio存储
 | 
					 * minio存储
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Lion Li
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class MinioCloudStorageServiceImpl extends AbstractCloudStorageService {
 | 
					@Lazy
 | 
				
			||||||
 | 
					@Service
 | 
				
			||||||
 | 
					public class MinioCloudStorageServiceImpl extends AbstractCloudStorageService implements InitializingBean {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private MinioClient minioClient;
 | 
						private final MinioClient minioClient;
 | 
				
			||||||
 | 
						private final MinioProperties properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public MinioCloudStorageServiceImpl(CloudStorageConfig config) {
 | 
						@Autowired
 | 
				
			||||||
		this.config = config;
 | 
						public MinioCloudStorageServiceImpl(CloudStorageProperties properties) {
 | 
				
			||||||
		// 初始化
 | 
							this.properties = properties.getMinio();
 | 
				
			||||||
		init();
 | 
							minioClient = MinioClient.builder()
 | 
				
			||||||
 | 
								.endpoint(this.properties.getEndpoint())
 | 
				
			||||||
 | 
								.credentials(this.properties.getAccessKey(), this.properties.getSecretKey())
 | 
				
			||||||
 | 
								.build();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private void init() {
 | 
						@Override
 | 
				
			||||||
		minioClient = MinioClient.builder()
 | 
						public String getServiceType() {
 | 
				
			||||||
			.endpoint(config.getDomain())
 | 
							return CloudServiceEnumd.MINIO.getValue();
 | 
				
			||||||
			.credentials(config.getAccessKey(), config.getSecretKey())
 | 
					 | 
				
			||||||
			.build();
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
@@ -35,7 +47,7 @@ public class MinioCloudStorageServiceImpl extends AbstractCloudStorageService {
 | 
				
			|||||||
		} catch (Exception e) {
 | 
							} catch (Exception e) {
 | 
				
			||||||
			throw new OssException("上传文件失败,请核对Minio配置信息");
 | 
								throw new OssException("上传文件失败,请核对Minio配置信息");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return config.getDomain() + "/" + path;
 | 
							return this.properties.getEndpoint() + "/" + path;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
@@ -47,20 +59,18 @@ public class MinioCloudStorageServiceImpl extends AbstractCloudStorageService {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
					 | 
				
			||||||
	public String upload(InputStream inputStream, String path) {
 | 
					 | 
				
			||||||
		byte[] data = IoUtil.readBytes(inputStream);
 | 
					 | 
				
			||||||
		return this.upload(data, path);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public String uploadSuffix(byte[] data, String suffix) {
 | 
						public String uploadSuffix(byte[] data, String suffix) {
 | 
				
			||||||
		return upload(data, getPath(config.getPrefix(), suffix));
 | 
							return upload(data, getPath(this.properties.getPrefix(), suffix));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public String uploadSuffix(InputStream inputStream, String suffix) {
 | 
						public String uploadSuffix(InputStream inputStream, String suffix) {
 | 
				
			||||||
		return upload(inputStream, getPath(config.getPrefix(), suffix));
 | 
							return upload(inputStream, getPath(this.properties.getPrefix(), suffix));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void afterPropertiesSet() throws Exception {
 | 
				
			||||||
 | 
							OssFactory.register(getServiceType(),this);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,33 +1,50 @@
 | 
				
			|||||||
package com.ruoyi.oss.service.impl;
 | 
					package com.ruoyi.oss.service.impl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import cn.hutool.core.io.IoUtil;
 | 
					 | 
				
			||||||
import com.qcloud.cos.COSClient;
 | 
					import com.qcloud.cos.COSClient;
 | 
				
			||||||
import com.ruoyi.oss.config.CloudStorageConfig;
 | 
					import com.qcloud.cos.ClientConfig;
 | 
				
			||||||
 | 
					import com.qcloud.cos.auth.BasicCOSCredentials;
 | 
				
			||||||
 | 
					import com.qcloud.cos.auth.COSCredentials;
 | 
				
			||||||
 | 
					import com.qcloud.cos.region.Region;
 | 
				
			||||||
 | 
					import com.ruoyi.oss.enumd.CloudServiceEnumd;
 | 
				
			||||||
 | 
					import com.ruoyi.oss.factory.OssFactory;
 | 
				
			||||||
 | 
					import com.ruoyi.oss.properties.CloudStorageProperties;
 | 
				
			||||||
 | 
					import com.ruoyi.oss.properties.QcloudProperties;
 | 
				
			||||||
import com.ruoyi.oss.service.abstractd.AbstractCloudStorageService;
 | 
					import com.ruoyi.oss.service.abstractd.AbstractCloudStorageService;
 | 
				
			||||||
 | 
					import org.springframework.beans.factory.InitializingBean;
 | 
				
			||||||
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
 | 
					import org.springframework.context.annotation.Lazy;
 | 
				
			||||||
 | 
					import org.springframework.stereotype.Service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.InputStream;
 | 
					import java.io.InputStream;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 腾讯云存储
 | 
					 * 腾讯云存储
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Lion Li
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class QcloudCloudStorageServiceImpl extends AbstractCloudStorageService {
 | 
					@Lazy
 | 
				
			||||||
 | 
					@Service
 | 
				
			||||||
 | 
					public class QcloudCloudStorageServiceImpl extends AbstractCloudStorageService implements InitializingBean {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private COSClient client;
 | 
						private final COSClient client;
 | 
				
			||||||
 | 
						private final QcloudProperties properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public QcloudCloudStorageServiceImpl(CloudStorageConfig config) {
 | 
						@Autowired
 | 
				
			||||||
		this.config = config;
 | 
						public QcloudCloudStorageServiceImpl(CloudStorageProperties properties) {
 | 
				
			||||||
		// 初始化
 | 
							this.properties = properties.getQcloud();
 | 
				
			||||||
		init();
 | 
					        COSCredentials credentials = new BasicCOSCredentials(
 | 
				
			||||||
 | 
								this.properties.getSecretId(),
 | 
				
			||||||
 | 
								this.properties.getSecretKey());
 | 
				
			||||||
 | 
					        // 初始化客户端配置
 | 
				
			||||||
 | 
					        ClientConfig clientConfig = new ClientConfig();
 | 
				
			||||||
 | 
					        // 设置bucket所在的区域,华南:gz 华北:tj 华东:sh
 | 
				
			||||||
 | 
					        clientConfig.setRegion(new Region(this.properties.getRegion()));
 | 
				
			||||||
 | 
					        client = new COSClient(credentials, clientConfig);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private void init() {
 | 
						@Override
 | 
				
			||||||
//        Credentials credentials = new Credentials(config.getQcloudAppId(), config.getQcloudSecretId(),
 | 
						public String getServiceType() {
 | 
				
			||||||
//                config.getQcloudSecretKey());
 | 
							return CloudServiceEnumd.QCLOUD.getValue();
 | 
				
			||||||
//         初始化客户端配置
 | 
					 | 
				
			||||||
//        ClientConfig clientConfig = new ClientConfig();
 | 
					 | 
				
			||||||
//        // 设置bucket所在的区域,华南:gz 华北:tj 华东:sh
 | 
					 | 
				
			||||||
//        clientConfig.setRegion(config.getQcloudRegion());
 | 
					 | 
				
			||||||
//        client = new COSClient(clientConfig, credentials);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
@@ -43,7 +60,7 @@ public class QcloudCloudStorageServiceImpl extends AbstractCloudStorageService {
 | 
				
			|||||||
//        if (Convert.toInt(jsonObject.get("code")) != 0) {
 | 
					//        if (Convert.toInt(jsonObject.get("code")) != 0) {
 | 
				
			||||||
//            throw new OssException("文件上传失败," + Convert.toStr(jsonObject.get("message")));
 | 
					//            throw new OssException("文件上传失败," + Convert.toStr(jsonObject.get("message")));
 | 
				
			||||||
//        }
 | 
					//        }
 | 
				
			||||||
		return config.getDomain() + path;
 | 
							return this.properties.getDomain() + path;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
@@ -57,21 +74,18 @@ public class QcloudCloudStorageServiceImpl extends AbstractCloudStorageService {
 | 
				
			|||||||
//        }
 | 
					//        }
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
	@Override
 | 
					 | 
				
			||||||
	public String upload(InputStream inputStream, String path) {
 | 
					 | 
				
			||||||
		byte[] data = IoUtil.readBytes(inputStream);
 | 
					 | 
				
			||||||
		return this.upload(data, path);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public String uploadSuffix(byte[] data, String suffix) {
 | 
						public String uploadSuffix(byte[] data, String suffix) {
 | 
				
			||||||
		return upload(data, getPath(config.getPrefix(), suffix));
 | 
							return upload(data, getPath(this.properties.getPrefix(), suffix));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public String uploadSuffix(InputStream inputStream, String suffix) {
 | 
						public String uploadSuffix(InputStream inputStream, String suffix) {
 | 
				
			||||||
		return upload(inputStream, getPath(config.getPrefix(), suffix));
 | 
							return upload(inputStream, getPath(this.properties.getPrefix(), suffix));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void afterPropertiesSet() throws Exception {
 | 
				
			||||||
 | 
							OssFactory.register(getServiceType(),this);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,44 +1,59 @@
 | 
				
			|||||||
package com.ruoyi.oss.service.impl;
 | 
					package com.ruoyi.oss.service.impl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import cn.hutool.core.io.IoUtil;
 | 
					 | 
				
			||||||
import com.qiniu.http.Response;
 | 
					import com.qiniu.http.Response;
 | 
				
			||||||
import com.qiniu.storage.BucketManager;
 | 
					import com.qiniu.storage.BucketManager;
 | 
				
			||||||
import com.qiniu.storage.Configuration;
 | 
					import com.qiniu.storage.Configuration;
 | 
				
			||||||
import com.qiniu.storage.Region;
 | 
					import com.qiniu.storage.Region;
 | 
				
			||||||
import com.qiniu.storage.UploadManager;
 | 
					import com.qiniu.storage.UploadManager;
 | 
				
			||||||
import com.qiniu.util.Auth;
 | 
					import com.qiniu.util.Auth;
 | 
				
			||||||
import com.ruoyi.oss.config.CloudStorageConfig;
 | 
					import com.ruoyi.oss.enumd.CloudServiceEnumd;
 | 
				
			||||||
import com.ruoyi.oss.exception.OssException;
 | 
					import com.ruoyi.oss.exception.OssException;
 | 
				
			||||||
 | 
					import com.ruoyi.oss.factory.OssFactory;
 | 
				
			||||||
 | 
					import com.ruoyi.oss.properties.CloudStorageProperties;
 | 
				
			||||||
 | 
					import com.ruoyi.oss.properties.QiniuProperties;
 | 
				
			||||||
import com.ruoyi.oss.service.abstractd.AbstractCloudStorageService;
 | 
					import com.ruoyi.oss.service.abstractd.AbstractCloudStorageService;
 | 
				
			||||||
 | 
					import org.springframework.beans.factory.InitializingBean;
 | 
				
			||||||
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
 | 
					import org.springframework.context.annotation.Lazy;
 | 
				
			||||||
 | 
					import org.springframework.stereotype.Service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.InputStream;
 | 
					import java.io.InputStream;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 七牛云存储
 | 
					 * 七牛云存储
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Lion Li
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class QiniuCloudStorageServiceImpl extends AbstractCloudStorageService {
 | 
					@Lazy
 | 
				
			||||||
 | 
					@Service
 | 
				
			||||||
 | 
					public class QiniuCloudStorageServiceImpl extends AbstractCloudStorageService implements InitializingBean {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private UploadManager uploadManager;
 | 
						private final UploadManager uploadManager;
 | 
				
			||||||
	private BucketManager bucketManager;
 | 
						private final BucketManager bucketManager;
 | 
				
			||||||
	private String token;
 | 
						private final String token;
 | 
				
			||||||
 | 
						private final QiniuProperties properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public QiniuCloudStorageServiceImpl(CloudStorageConfig config) {
 | 
						@Autowired
 | 
				
			||||||
		this.config = config;
 | 
						public QiniuCloudStorageServiceImpl(CloudStorageProperties properties) {
 | 
				
			||||||
		// 初始化
 | 
							this.properties = properties.getQiniu();
 | 
				
			||||||
		init();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	private void init() {
 | 
					 | 
				
			||||||
		// z0 z1 z2
 | 
							// z0 z1 z2
 | 
				
			||||||
		Configuration config = new Configuration(Region.autoRegion());
 | 
							Configuration config = new Configuration(Region.autoRegion());
 | 
				
			||||||
		// 默认不使用https
 | 
							// 默认不使用https
 | 
				
			||||||
		config.useHttpsDomains = false;
 | 
							config.useHttpsDomains = false;
 | 
				
			||||||
		uploadManager = new UploadManager(config);
 | 
							uploadManager = new UploadManager(config);
 | 
				
			||||||
		Auth auth = Auth.create(this.config.getAccessKey(), this.config.getSecretKey());
 | 
							Auth auth = Auth.create(
 | 
				
			||||||
		token = auth.uploadToken(this.config.getBucketName());
 | 
								this.properties.getAccessKey(),
 | 
				
			||||||
 | 
								this.properties.getSecretKey());
 | 
				
			||||||
 | 
							token = auth.uploadToken(this.properties.getBucketName());
 | 
				
			||||||
		bucketManager = new BucketManager(auth, config);
 | 
							bucketManager = new BucketManager(auth, config);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public String getServiceType() {
 | 
				
			||||||
 | 
							return CloudServiceEnumd.QINIU.getValue();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public String upload(byte[] data, String path) {
 | 
						public String upload(byte[] data, String path) {
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
@@ -49,14 +64,14 @@ public class QiniuCloudStorageServiceImpl extends AbstractCloudStorageService {
 | 
				
			|||||||
		} catch (Exception e) {
 | 
							} catch (Exception e) {
 | 
				
			||||||
			throw new OssException("上传文件失败,请核对七牛配置信息");
 | 
								throw new OssException("上传文件失败,请核对七牛配置信息");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return config.getDomain() + "/" + path;
 | 
							return this.properties.getDomain() + "/" + path;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void delete(String path) {
 | 
						public void delete(String path) {
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			path = path.replace(config.getDomain() + "/", "");
 | 
								path = path.replace(this.properties.getDomain() + "/", "");
 | 
				
			||||||
			Response res = bucketManager.delete(config.getBucketName(), path);
 | 
								Response res = bucketManager.delete(this.properties.getBucketName(), path);
 | 
				
			||||||
			if (!res.isOK()) {
 | 
								if (!res.isOK()) {
 | 
				
			||||||
				throw new RuntimeException("删除七牛文件出错:" + res.toString());
 | 
									throw new RuntimeException("删除七牛文件出错:" + res.toString());
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -65,20 +80,19 @@ public class QiniuCloudStorageServiceImpl extends AbstractCloudStorageService {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
					 | 
				
			||||||
	public String upload(InputStream inputStream, String path) {
 | 
					 | 
				
			||||||
		byte[] data = IoUtil.readBytes(inputStream);
 | 
					 | 
				
			||||||
		return this.upload(data, path);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public String uploadSuffix(byte[] data, String suffix) {
 | 
						public String uploadSuffix(byte[] data, String suffix) {
 | 
				
			||||||
		return upload(data, getPath(config.getPrefix(), suffix));
 | 
							return upload(data, getPath(this.properties.getPrefix(), suffix));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public String uploadSuffix(InputStream inputStream, String suffix) {
 | 
						public String uploadSuffix(InputStream inputStream, String suffix) {
 | 
				
			||||||
		return upload(inputStream, getPath(config.getPrefix(), suffix));
 | 
							return upload(inputStream, getPath(this.properties.getPrefix(), suffix));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void afterPropertiesSet() throws Exception {
 | 
				
			||||||
 | 
							OssFactory.register(getServiceType(),this);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,135 +0,0 @@
 | 
				
			|||||||
package com.ruoyi.oss.utils;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import org.apache.commons.lang3.time.DateFormatUtils;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.lang.management.ManagementFactory;
 | 
					 | 
				
			||||||
import java.text.ParseException;
 | 
					 | 
				
			||||||
import java.text.SimpleDateFormat;
 | 
					 | 
				
			||||||
import java.util.Date;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * 时间工具类
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * @author ruoyi
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 | 
					 | 
				
			||||||
	public static String YYYY = "yyyy";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public static String YYYY_MM = "yyyy-MM";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public static String YYYY_MM_DD = "yyyy-MM-dd";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	private static String[] parsePatterns = {
 | 
					 | 
				
			||||||
		"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
 | 
					 | 
				
			||||||
		"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
 | 
					 | 
				
			||||||
		"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 获取当前Date型日期
 | 
					 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @return Date() 当前日期
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	public static Date getNowDate() {
 | 
					 | 
				
			||||||
		return new Date();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 获取当前日期, 默认格式为yyyy-MM-dd
 | 
					 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @return String
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	public static String getDate() {
 | 
					 | 
				
			||||||
		return dateTimeNow(YYYY_MM_DD);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public static final String getTime() {
 | 
					 | 
				
			||||||
		return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public static final String dateTimeNow() {
 | 
					 | 
				
			||||||
		return dateTimeNow(YYYYMMDDHHMMSS);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public static final String dateTimeNow(final String format) {
 | 
					 | 
				
			||||||
		return parseDateToStr(format, new Date());
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public static final String dateTime(final Date date) {
 | 
					 | 
				
			||||||
		return parseDateToStr(YYYY_MM_DD, date);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public static final String parseDateToStr(final String format, final Date date) {
 | 
					 | 
				
			||||||
		return new SimpleDateFormat(format).format(date);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public static final Date dateTime(final String format, final String ts) {
 | 
					 | 
				
			||||||
		try {
 | 
					 | 
				
			||||||
			return new SimpleDateFormat(format).parse(ts);
 | 
					 | 
				
			||||||
		} catch (ParseException e) {
 | 
					 | 
				
			||||||
			throw new RuntimeException(e);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 日期路径 即年/月/日 如2018/08/08
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	public static final String datePath() {
 | 
					 | 
				
			||||||
		Date now = new Date();
 | 
					 | 
				
			||||||
		return DateFormatUtils.format(now, "yyyy/MM/dd");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 日期路径 即年/月/日 如20180808
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	public static final String dateTime() {
 | 
					 | 
				
			||||||
		Date now = new Date();
 | 
					 | 
				
			||||||
		return DateFormatUtils.format(now, "yyyyMMdd");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 日期型字符串转化为日期 格式
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	public static Date parseDate(Object str) {
 | 
					 | 
				
			||||||
		if (str == null) {
 | 
					 | 
				
			||||||
			return null;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		try {
 | 
					 | 
				
			||||||
			return parseDate(str.toString(), parsePatterns);
 | 
					 | 
				
			||||||
		} catch (ParseException e) {
 | 
					 | 
				
			||||||
			return null;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 获取服务器启动时间
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	public static Date getServerStartDate() {
 | 
					 | 
				
			||||||
		long time = ManagementFactory.getRuntimeMXBean().getStartTime();
 | 
					 | 
				
			||||||
		return new Date(time);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 计算两个时间差
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	public static String getDatePoor(Date endDate, Date nowDate) {
 | 
					 | 
				
			||||||
		long nd = 1000 * 24 * 60 * 60;
 | 
					 | 
				
			||||||
		long nh = 1000 * 60 * 60;
 | 
					 | 
				
			||||||
		long nm = 1000 * 60;
 | 
					 | 
				
			||||||
		// long ns = 1000;
 | 
					 | 
				
			||||||
		// 获得两个时间的毫秒时间差异
 | 
					 | 
				
			||||||
		long diff = endDate.getTime() - nowDate.getTime();
 | 
					 | 
				
			||||||
		// 计算差多少天
 | 
					 | 
				
			||||||
		long day = diff / nd;
 | 
					 | 
				
			||||||
		// 计算差多少小时
 | 
					 | 
				
			||||||
		long hour = diff % nd / nh;
 | 
					 | 
				
			||||||
		// 计算差多少分钟
 | 
					 | 
				
			||||||
		long min = diff % nd % nh / nm;
 | 
					 | 
				
			||||||
		// 计算差多少秒//输出结果
 | 
					 | 
				
			||||||
		// long sec = diff % nd % nh % nm / ns;
 | 
					 | 
				
			||||||
		return day + "天" + hour + "小时" + min + "分钟";
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,58 +1,74 @@
 | 
				
			|||||||
package com.ruoyi.system.controller;
 | 
					package com.ruoyi.system.controller;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.aliyun.oss.ServiceException;
 | 
					import com.ruoyi.common.annotation.Log;
 | 
				
			||||||
 | 
					import com.ruoyi.common.annotation.RepeatSubmit;
 | 
				
			||||||
import com.ruoyi.common.core.controller.BaseController;
 | 
					import com.ruoyi.common.core.controller.BaseController;
 | 
				
			||||||
import com.ruoyi.common.core.domain.AjaxResult;
 | 
					import com.ruoyi.common.core.domain.AjaxResult;
 | 
				
			||||||
import com.ruoyi.common.core.page.TableDataInfo;
 | 
					import com.ruoyi.common.core.page.TableDataInfo;
 | 
				
			||||||
 | 
					import com.ruoyi.common.enums.BusinessType;
 | 
				
			||||||
import com.ruoyi.common.exception.CustomException;
 | 
					import com.ruoyi.common.exception.CustomException;
 | 
				
			||||||
import com.ruoyi.common.utils.PageUtils;
 | 
					 | 
				
			||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
 | 
					 | 
				
			||||||
import com.ruoyi.system.domain.SysOss;
 | 
					import com.ruoyi.system.domain.SysOss;
 | 
				
			||||||
import com.ruoyi.system.service.ISysOssService;
 | 
					import com.ruoyi.system.service.ISysOssService;
 | 
				
			||||||
import lombok.extern.slf4j.Slf4j;
 | 
					import lombok.RequiredArgsConstructor;
 | 
				
			||||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
import org.springframework.stereotype.Controller;
 | 
					import org.springframework.security.access.prepost.PreAuthorize;
 | 
				
			||||||
import org.springframework.ui.ModelMap;
 | 
					 | 
				
			||||||
import org.springframework.web.bind.annotation.*;
 | 
					import org.springframework.web.bind.annotation.*;
 | 
				
			||||||
import org.springframework.web.multipart.MultipartFile;
 | 
					import org.springframework.web.multipart.MultipartFile;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.List;
 | 
					import javax.validation.constraints.NotEmpty;
 | 
				
			||||||
 | 
					import java.util.Arrays;
 | 
				
			||||||
 | 
					import java.util.HashMap;
 | 
				
			||||||
import java.util.Map;
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 文件上传 控制层
 | 
					 * 文件上传 控制层
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author chkj
 | 
					 * @author Lion Li
 | 
				
			||||||
 * @date 2019-07-15
 | 
					 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@Slf4j
 | 
					@RequiredArgsConstructor(onConstructor_ = @Autowired)
 | 
				
			||||||
@RestController
 | 
					@RestController
 | 
				
			||||||
@RequestMapping("/system/oss")
 | 
					@RequestMapping("/system/oss")
 | 
				
			||||||
public class SysOssController extends BaseController {
 | 
					public class SysOssController extends BaseController {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Autowired
 | 
						private final ISysOssService iSysOssService;
 | 
				
			||||||
	private ISysOssService iSysOssService;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * 查询文件上传列表
 | 
						 * 查询文件上传列表
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
 | 
						@PreAuthorize("@ss.hasPermi('system:oss:list')")
 | 
				
			||||||
	@GetMapping("/list")
 | 
						@GetMapping("/list")
 | 
				
			||||||
	public TableDataInfo list(SysOss sysOss) {
 | 
						public TableDataInfo<SysOss> list(SysOss sysOss) {
 | 
				
			||||||
		List<SysOss> list = iSysOssService.list(sysOss);
 | 
							return iSysOssService.queryPageList(sysOss);
 | 
				
			||||||
		return PageUtils.buildDataInfo(list);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * 上传图片
 | 
						 * 上传图片
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
 | 
						@PreAuthorize("@ss.hasPermi('system:oss:upload')")
 | 
				
			||||||
 | 
						@Log(title = "OSS云存储", businessType = BusinessType.INSERT)
 | 
				
			||||||
 | 
						@RepeatSubmit
 | 
				
			||||||
	@PostMapping("/upload")
 | 
						@PostMapping("/upload")
 | 
				
			||||||
	public AjaxResult upload(@RequestParam("file") MultipartFile file) {
 | 
						public AjaxResult<Map<String, String>> upload(@RequestParam("file") MultipartFile file) {
 | 
				
			||||||
		if (file.isEmpty()) {
 | 
							if (file.isEmpty()) {
 | 
				
			||||||
			throw new CustomException("上传文件不能为空");
 | 
								throw new CustomException("上传文件不能为空");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		Map<String, String> json = iSysOssService.upload(file);
 | 
							SysOss oss = iSysOssService.upload(file);
 | 
				
			||||||
		return AjaxResult.success(json);
 | 
							Map<String, String> map = new HashMap<>(2);
 | 
				
			||||||
 | 
							map.put("url", oss.getUrl());
 | 
				
			||||||
 | 
							map.put("fileName", oss.getFileName());
 | 
				
			||||||
 | 
							return AjaxResult.success(map);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 删除OSS云存储
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@PreAuthorize("@ss.hasPermi('system:oss:remove')")
 | 
				
			||||||
 | 
						@Log(title = "OSS云存储" , businessType = BusinessType.DELETE)
 | 
				
			||||||
 | 
						@DeleteMapping("/{ossIds}")
 | 
				
			||||||
 | 
						public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
 | 
				
			||||||
 | 
													   @PathVariable Long[] ossIds) {
 | 
				
			||||||
 | 
							return toAjax(iSysOssService.deleteByIds(Arrays.asList(ossIds)) ? 1 : 0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,20 +9,24 @@ import java.io.Serializable;
 | 
				
			|||||||
import java.util.Date;
 | 
					import java.util.Date;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 文件上传表 sys_oss
 | 
					 * OSS云存储对象
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author chkj
 | 
					 * @author Lion Li
 | 
				
			||||||
 * @date 2019-07-15
 | 
					 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@Data
 | 
					@Data
 | 
				
			||||||
@Accessors(chain = true)
 | 
					 | 
				
			||||||
@NoArgsConstructor
 | 
					@NoArgsConstructor
 | 
				
			||||||
 | 
					@Accessors(chain = true)
 | 
				
			||||||
@TableName("sys_oss")
 | 
					@TableName("sys_oss")
 | 
				
			||||||
public class SysOss implements Serializable {
 | 
					public class SysOss implements Serializable {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private static final long serialVersionUID = 1L;
 | 
						private static final long serialVersionUID = 1L;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@TableId(value = "id", type = IdType.AUTO)
 | 
					
 | 
				
			||||||
	private Long id;
 | 
						/**
 | 
				
			||||||
 | 
						 * 云存储主键
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@TableId(value = "oss_id")
 | 
				
			||||||
 | 
						private Long ossId;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * 文件名
 | 
						 * 文件名
 | 
				
			||||||
@@ -51,8 +55,21 @@ public class SysOss implements Serializable {
 | 
				
			|||||||
	@TableField(fill = FieldFill.INSERT)
 | 
						@TableField(fill = FieldFill.INSERT)
 | 
				
			||||||
	private String createBy;
 | 
						private String createBy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 更新时间
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@TableField(fill = FieldFill.INSERT_UPDATE)
 | 
				
			||||||
 | 
						private Date updateTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 更新人
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@TableField(fill = FieldFill.INSERT_UPDATE)
 | 
				
			||||||
 | 
						private String updateBy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * 服务商
 | 
						 * 服务商
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	private Integer service;
 | 
						private String service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,31 +0,0 @@
 | 
				
			|||||||
package com.ruoyi.system.factory;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import com.ruoyi.oss.service.abstractd.AbstractCloudStorageService;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * 文件上传Factory
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
public class OSSFactory {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//    private static ISysConfigService sysConfigService;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	static {
 | 
					 | 
				
			||||||
//        OSSFactory.sysConfigService = SpringUtils.getBean(ISysConfigService.class);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public static AbstractCloudStorageService build() {
 | 
					 | 
				
			||||||
//        String jsonconfig = sysConfigService.selectConfigByKey(CloudConstant.CLOUD_STORAGE_CONFIG_KEY);
 | 
					 | 
				
			||||||
//        // 获取云存储配置信息
 | 
					 | 
				
			||||||
//        CloudStorageConfig config = JSON.parseObject(jsonconfig, CloudStorageConfig.class);
 | 
					 | 
				
			||||||
//        if (config.getType() == CloudConstant.CloudService.QINIU.getValue()) {
 | 
					 | 
				
			||||||
//            return new QiniuCloudStorageServiceImpl(config);
 | 
					 | 
				
			||||||
//        } else if (config.getType() == CloudConstant.CloudService.ALIYUN.getValue()) {
 | 
					 | 
				
			||||||
//            return new AliyunCloudStorageServiceImpl(config);
 | 
					 | 
				
			||||||
//        } else if (config.getType() == CloudConstant.CloudService.QCLOUD.getValue()) {
 | 
					 | 
				
			||||||
//            return new QcloudCloudStorageServiceImpl(config);
 | 
					 | 
				
			||||||
//        } else if (config.getType() == CloudConstant.CloudService.MINIO.getValue()) {
 | 
					 | 
				
			||||||
//			return new MinioCloudStorageServiceImpl(config);
 | 
					 | 
				
			||||||
//		}
 | 
					 | 
				
			||||||
		return null;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -6,8 +6,7 @@ import com.ruoyi.system.domain.SysOss;
 | 
				
			|||||||
/**
 | 
					/**
 | 
				
			||||||
 * 文件上传 数据层
 | 
					 * 文件上传 数据层
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author chkj
 | 
					 * @author Lion Li
 | 
				
			||||||
 * @date 2019-07-15
 | 
					 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public interface SysOssMapper extends BaseMapper<SysOss> {
 | 
					public interface SysOssMapper extends BaseMapper<SysOss> {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,24 +1,22 @@
 | 
				
			|||||||
package com.ruoyi.system.service;
 | 
					package com.ruoyi.system.service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.baomidou.mybatisplus.extension.service.IService;
 | 
					import com.baomidou.mybatisplus.extension.service.IService;
 | 
				
			||||||
 | 
					import com.ruoyi.common.core.page.TableDataInfo;
 | 
				
			||||||
import com.ruoyi.system.domain.SysOss;
 | 
					import com.ruoyi.system.domain.SysOss;
 | 
				
			||||||
import org.springframework.web.multipart.MultipartFile;
 | 
					import org.springframework.web.multipart.MultipartFile;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.Collection;
 | 
				
			||||||
import java.util.Map;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 文件上传 服务层
 | 
					 * 文件上传 服务层
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author chkj
 | 
					 * @author Lion Li
 | 
				
			||||||
 * @date 2019-07-15
 | 
					 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public interface ISysOssService extends IService<SysOss> {
 | 
					public interface ISysOssService extends IService<SysOss> {
 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * 列表查询
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	List<SysOss> list(SysOss sysOss);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Map<String, String> upload(MultipartFile file);
 | 
						TableDataInfo<SysOss> queryPageList(SysOss sysOss);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						SysOss upload(MultipartFile file);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Boolean deleteByIds(Collection<Long> ids);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,63 +1,71 @@
 | 
				
			|||||||
package com.ruoyi.system.service.impl;
 | 
					package com.ruoyi.system.service.impl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cn.hutool.core.util.StrUtil;
 | 
				
			||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
					import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
				
			||||||
 | 
					import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 | 
				
			||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
					import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
				
			||||||
 | 
					import com.ruoyi.common.core.page.TableDataInfo;
 | 
				
			||||||
import com.ruoyi.common.exception.CustomException;
 | 
					import com.ruoyi.common.exception.CustomException;
 | 
				
			||||||
import com.ruoyi.oss.config.CloudStorageConfig;
 | 
					import com.ruoyi.common.utils.PageUtils;
 | 
				
			||||||
import com.ruoyi.oss.service.abstractd.AbstractCloudStorageService;
 | 
					import com.ruoyi.oss.factory.OssFactory;
 | 
				
			||||||
 | 
					import com.ruoyi.oss.service.ICloudStorageService;
 | 
				
			||||||
import com.ruoyi.system.domain.SysOss;
 | 
					import com.ruoyi.system.domain.SysOss;
 | 
				
			||||||
import com.ruoyi.system.factory.OSSFactory;
 | 
					 | 
				
			||||||
import com.ruoyi.system.mapper.SysOssMapper;
 | 
					import com.ruoyi.system.mapper.SysOssMapper;
 | 
				
			||||||
import com.ruoyi.system.service.ISysOssService;
 | 
					import com.ruoyi.system.service.ISysOssService;
 | 
				
			||||||
import lombok.extern.slf4j.Slf4j;
 | 
					import lombok.extern.slf4j.Slf4j;
 | 
				
			||||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
					 | 
				
			||||||
import org.springframework.stereotype.Service;
 | 
					import org.springframework.stereotype.Service;
 | 
				
			||||||
import org.springframework.web.multipart.MultipartFile;
 | 
					import org.springframework.web.multipart.MultipartFile;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
import java.util.HashMap;
 | 
					import java.util.Collection;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
import java.util.Map;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 文件上传 服务层实现
 | 
					 * 文件上传 服务层实现
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author chkj
 | 
					 * @author Lion Li
 | 
				
			||||||
 * @date 2019-07-15
 | 
					 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@Slf4j
 | 
					@Slf4j
 | 
				
			||||||
@Service
 | 
					@Service
 | 
				
			||||||
public class SysOssServiceImpl extends ServiceImpl<SysOssMapper, SysOss> implements ISysOssService {
 | 
					public class SysOssServiceImpl extends ServiceImpl<SysOssMapper, SysOss> implements ISysOssService {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Autowired
 | 
					 | 
				
			||||||
	private CloudStorageConfig config;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public List<SysOss> list(SysOss sysOss) {
 | 
						public TableDataInfo<SysOss> queryPageList(SysOss sysOss) {
 | 
				
			||||||
		LambdaQueryWrapper<SysOss> wrapper = new LambdaQueryWrapper<>();
 | 
							LambdaQueryWrapper<SysOss> lqw = Wrappers.lambdaQuery();
 | 
				
			||||||
		return baseMapper.selectList(wrapper);
 | 
							lqw.like(StrUtil.isNotBlank(sysOss.getFileName()), SysOss::getFileName, sysOss.getFileName());
 | 
				
			||||||
 | 
							lqw.like(StrUtil.isNotBlank(sysOss.getFileSuffix()), SysOss::getFileSuffix, sysOss.getFileSuffix());
 | 
				
			||||||
 | 
							lqw.like(StrUtil.isNotBlank(sysOss.getUrl()), SysOss::getUrl, sysOss.getUrl());
 | 
				
			||||||
 | 
							lqw.like(StrUtil.isNotBlank(sysOss.getService()), SysOss::getService, sysOss.getService());
 | 
				
			||||||
 | 
							return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public Map<String, String> upload(MultipartFile file) {
 | 
						public SysOss upload(MultipartFile file) {
 | 
				
			||||||
		String originalfileName = file.getOriginalFilename();
 | 
							String originalfileName = file.getOriginalFilename();
 | 
				
			||||||
		String suffix = originalfileName.substring(originalfileName.lastIndexOf("."));
 | 
							String suffix = StrUtil.sub(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length());
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			AbstractCloudStorageService storage = OSSFactory.build();
 | 
								ICloudStorageService storage = OssFactory.instance();
 | 
				
			||||||
			String url = storage.uploadSuffix(file.getBytes(), suffix);
 | 
								String url = storage.uploadSuffix(file.getBytes(), suffix);
 | 
				
			||||||
			// 保存文件信息
 | 
								// 保存文件信息
 | 
				
			||||||
			SysOss ossEntity = new SysOss()
 | 
								SysOss oss = new SysOss()
 | 
				
			||||||
				.setUrl(url).setFileSuffix(suffix)
 | 
									.setUrl(url).setFileSuffix(suffix)
 | 
				
			||||||
				.setFileName(originalfileName)
 | 
									.setFileName(originalfileName)
 | 
				
			||||||
				.setService(storage.getServiceType());
 | 
									.setService(storage.getServiceType());
 | 
				
			||||||
			save(ossEntity);
 | 
								save(oss);
 | 
				
			||||||
			Map<String, String> map = new HashMap<>(2);
 | 
								return oss;
 | 
				
			||||||
			map.put("url", ossEntity.getUrl());
 | 
					 | 
				
			||||||
			map.put("fileName", ossEntity.getFileName());
 | 
					 | 
				
			||||||
			return map;
 | 
					 | 
				
			||||||
		} catch (IOException e) {
 | 
							} catch (IOException e) {
 | 
				
			||||||
			throw new CustomException("文件读取异常!!!", e);
 | 
								throw new CustomException("文件读取异常!!!", e);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public Boolean deleteByIds(Collection<Long> ids) {
 | 
				
			||||||
 | 
							List<SysOss> list = listByIds(ids);
 | 
				
			||||||
 | 
							for (SysOss sysOss : list) {
 | 
				
			||||||
 | 
								ICloudStorageService storage = OssFactory.instance(sysOss.getService());
 | 
				
			||||||
 | 
								storage.delete(sysOss.getUrl());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return removeByIds(ids);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,21 +1,18 @@
 | 
				
			|||||||
<?xml version="1.0" encoding="UTF-8" ?>
 | 
					<?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">
 | 
					<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 | 
				
			||||||
<mapper namespace="com.chkj.cloudStorage.mapper.SysOssMapper">
 | 
					<mapper namespace="com.ruoyi.system.mapper.SysOssMapper">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <!-- 通用查询映射结果 -->
 | 
					    <resultMap type="com.ruoyi.system.domain.SysOss" id="SysOssResult">
 | 
				
			||||||
    <resultMap id="BaseResultMap" type="com.chkj.cloudStorage.domain.SysOss">
 | 
					        <result property="ossId" column="oss_id"/>
 | 
				
			||||||
        <id column="id" property="id"/>
 | 
					        <result property="fileName" column="file_name"/>
 | 
				
			||||||
        <result column="file_name" property="fileName"/>
 | 
					        <result property="fileSuffix" column="file_suffix"/>
 | 
				
			||||||
        <result column="file_suffix" property="fileSuffix"/>
 | 
					        <result property="url" column="url"/>
 | 
				
			||||||
        <result column="url" property="url"/>
 | 
					        <result property="createTime" column="create_time"/>
 | 
				
			||||||
        <result column="create_time" property="createTime"/>
 | 
					        <result property="createBy" column="create_by"/>
 | 
				
			||||||
        <result column="create_by" property="createBy"/>
 | 
					        <result property="updateTime" column="update_time"/>
 | 
				
			||||||
        <result column="service" property="service"/>
 | 
					        <result property="updateBy" column="update_by"/>
 | 
				
			||||||
 | 
					        <result property="service" column="service"/>
 | 
				
			||||||
    </resultMap>
 | 
					    </resultMap>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <!-- 通用查询结果列 -->
 | 
					 | 
				
			||||||
    <sql id="Base_Column_List">
 | 
					 | 
				
			||||||
        id, file_name, file_suffix, url, create_time, create_by, service
 | 
					 | 
				
			||||||
    </sql>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
</mapper>
 | 
					</mapper>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,30 +0,0 @@
 | 
				
			|||||||
CREATE TABLE `sys_oss`
 | 
					 | 
				
			||||||
(
 | 
					 | 
				
			||||||
    `id`          bigint(20)   NOT NULL AUTO_INCREMENT,
 | 
					 | 
				
			||||||
    `file_name`   varchar(64)  NOT NULL DEFAULT '' COMMENT '文件名',
 | 
					 | 
				
			||||||
    `file_suffix` varchar(10)  NOT NULL DEFAULT '' COMMENT '文件后缀名',
 | 
					 | 
				
			||||||
    `url`         varchar(200) NOT NULL COMMENT 'URL地址',
 | 
					 | 
				
			||||||
    `create_time` datetime              DEFAULT NULL COMMENT '创建时间',
 | 
					 | 
				
			||||||
    `create_by`   varchar(64)  NOT NULL DEFAULT '' COMMENT '上传人',
 | 
					 | 
				
			||||||
    `service`     tinyint(2)   NOT NULL DEFAULT '1' COMMENT '服务商',
 | 
					 | 
				
			||||||
    PRIMARY KEY (`id`)
 | 
					 | 
				
			||||||
) ENGINE = InnoDB
 | 
					 | 
				
			||||||
  AUTO_INCREMENT = 8
 | 
					 | 
				
			||||||
  DEFAULT CHARSET = utf8 COMMENT ='文件上传';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
INSERT INTO `ry`.`sys_menu` (`menu_name`, `parent_id`, `order_num`, `url`, `menu_type`, `visible`, `perms`, `icon`,
 | 
					 | 
				
			||||||
                             `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
 | 
					 | 
				
			||||||
VALUES ('文件管理', '1', '10', '/system/oss', 'C', '0', 'system:oss:view', '#', 'admin', '2018-11-16 13:59:45', '', NULL,
 | 
					 | 
				
			||||||
        '');
 | 
					 | 
				
			||||||
INSERT INTO `ry`.`sys_menu` (`menu_name`, `parent_id`, `order_num`, `url`, `menu_type`, `visible`, `perms`, `icon`,
 | 
					 | 
				
			||||||
                             `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
 | 
					 | 
				
			||||||
VALUES ('文件上传', '1056', '1', '#', 'F', '0', 'system:oss:add', '#', 'admin', '2018-11-16 13:59:45', '', NULL, '');
 | 
					 | 
				
			||||||
INSERT INTO `ry`.`sys_menu` (`menu_name`, `parent_id`, `order_num`, `url`, `menu_type`, `visible`, `perms`, `icon`,
 | 
					 | 
				
			||||||
                             `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
 | 
					 | 
				
			||||||
VALUES ('文件删除', '1056', '2', '#', 'F', '0', 'system:oss:remove', '#', 'admin', '2018-11-16 13:59:45', '', NULL, '');
 | 
					 | 
				
			||||||
INSERT INTO `ry`.`sys_menu` (`menu_name`, `parent_id`, `order_num`, `url`, `menu_type`, `visible`, `perms`, `icon`,
 | 
					 | 
				
			||||||
                             `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
 | 
					 | 
				
			||||||
VALUES ('文件配置', '1056', '3', '#', 'F', '0', 'system:oss:config', '#', 'admin', '2018-11-16 13:59:45', '', NULL, '');
 | 
					 | 
				
			||||||
INSERT INTO `ry`.`sys_menu` (`menu_name`, `parent_id`, `order_num`, `url`, `menu_type`, `visible`, `perms`, `icon`,
 | 
					 | 
				
			||||||
                             `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
 | 
					 | 
				
			||||||
VALUES ('文件修改', '1056', '4', '#', 'F', '0', 'system:oss:remove', '#', 'admin', '2018-11-16 13:59:45', '', NULL, '');
 | 
					 | 
				
			||||||
							
								
								
									
										24
									
								
								sql/oss.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								sql/oss.sql
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					-- ----------------------------
 | 
				
			||||||
 | 
					-- OSS云存储表
 | 
				
			||||||
 | 
					-- ----------------------------
 | 
				
			||||||
 | 
					drop table if exists sys_oss;
 | 
				
			||||||
 | 
					create table sys_oss (
 | 
				
			||||||
 | 
					    oss_id          bigint(20)   not null auto_increment    comment '云存储主键',
 | 
				
			||||||
 | 
					    file_name       varchar(64)  not null default ''        comment '文件名',
 | 
				
			||||||
 | 
					    file_suffix     varchar(10)  not null default ''        comment '文件后缀名',
 | 
				
			||||||
 | 
					    url              varchar(200) not null                   comment 'URL地址',
 | 
				
			||||||
 | 
					    create_time     datetime              default null      comment '创建时间',
 | 
				
			||||||
 | 
					    create_by       varchar(64)  not null default ''        comment '上传人',
 | 
				
			||||||
 | 
					    update_time     datetime              default null      comment '更新时间',
 | 
				
			||||||
 | 
					    update_by       varchar(64)  not null default ''        comment '更新人',
 | 
				
			||||||
 | 
					    service         varchar(10)  not null default 'minio'   comment '服务商',
 | 
				
			||||||
 | 
					    primary key (oss_id)
 | 
				
			||||||
 | 
					) engine=innodb comment ='OSS云存储表';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					insert into sys_config values(10, 'OSS云存储服务商',       'sys.oss.cloudStorageService',      'minio',          'Y', 'admin', sysdate(), '', null, 'OSS云存储服务商(qiniu:七牛云, aliyun:阿里云, qcloud:腾讯云, minio: Minio)');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					insert into sys_menu values('118',  '文件管理', '1',   '10', 'oss',     'system/oss/index',      1, 0, 'C', '0', '0', 'system:oss:list',      'oss',       'admin', sysdate(), '', null, '文件管理菜单');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					insert into sys_menu values('1600', '文件查询', '118', '1', '#', '', 1, 0, 'F', '0', '0', 'system:oss:query',        '#', 'admin', sysdate(), '', null, '');
 | 
				
			||||||
 | 
					insert into sys_menu values('1601', '文件上传', '118', '2', '#', '', 1, 0, 'F', '0', '0', 'system:oss:upload',       '#', 'admin', sysdate(), '', null, '');
 | 
				
			||||||
 | 
					insert into sys_menu values('1602', '文件删除', '118', '3', '#', '', 1, 0, 'F', '0', '0', 'system:oss:remove',       '#', 'admin', sysdate(), '', null, '');
 | 
				
			||||||
		Reference in New Issue
	
	Block a user