diff --git a/pom.xml b/pom.xml
index 8e6360e3e..ab460d4b1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,6 +33,8 @@
4.1.2
2.3
0.9.1
+ 7.9.0
+ 2.8.5
@@ -206,6 +208,18 @@
${private-farm.version}
+
+ com.qiniu
+ qiniu-java-sdk
+ ${qiniu.version}
+
+
+
+ com.google.code.gson
+ gson
+ ${gson.version}
+
+
diff --git a/private-farm/pom.xml b/private-farm/pom.xml
index 6e3d8e6d2..f600abe7b 100644
--- a/private-farm/pom.xml
+++ b/private-farm/pom.xml
@@ -19,6 +19,19 @@
com.ruoyi
ruoyi-common
+
+
+
+ com.qiniu
+ qiniu-java-sdk
+
+
+
+
+ com.google.code.gson
+ gson
+
+
\ No newline at end of file
diff --git a/private-farm/src/main/java/com/jlt/csa/task/QiniuConfiguration.java b/private-farm/src/main/java/com/jlt/csa/task/QiniuConfiguration.java
new file mode 100644
index 000000000..a43b87793
--- /dev/null
+++ b/private-farm/src/main/java/com/jlt/csa/task/QiniuConfiguration.java
@@ -0,0 +1,62 @@
+package com.jlt.csa.task;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "qiniu")
+public class QiniuConfiguration {
+ private Boolean enabled;
+ private Boolean isUse;
+ private String accessKey;
+ private String secretKey;
+ private String bucket;
+
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public Boolean getIsUse() {
+ return isUse;
+ }
+
+ public void setIsUse(Boolean use) {
+ isUse = use;
+ }
+
+ public String getAccessKey() {
+ return accessKey;
+ }
+
+ public void setAccessKey(String accessKey) {
+ this.accessKey = accessKey;
+ }
+
+ public String getSecretKey() {
+ return secretKey;
+ }
+
+ public void setSecretKey(String secretKey) {
+ this.secretKey = secretKey;
+ }
+
+ public Boolean getUse() {
+ return isUse;
+ }
+
+ public void setUse(Boolean use) {
+ isUse = use;
+ }
+
+ public String getBucket() {
+ return bucket;
+ }
+
+ public void setBucket(String bucket) {
+ this.bucket = bucket;
+ }
+}
diff --git a/private-farm/src/main/java/com/jlt/csa/task/QiniuOssTask.java b/private-farm/src/main/java/com/jlt/csa/task/QiniuOssTask.java
new file mode 100644
index 000000000..865faa8d0
--- /dev/null
+++ b/private-farm/src/main/java/com/jlt/csa/task/QiniuOssTask.java
@@ -0,0 +1,97 @@
+package com.jlt.csa.task;
+
+import com.qiniu.common.QiniuException;
+import com.qiniu.http.Response;
+import com.qiniu.storage.Configuration;
+import com.qiniu.storage.Region;
+import com.qiniu.storage.UploadManager;
+import com.qiniu.storage.model.DefaultPutRet;
+import com.qiniu.util.Auth;
+import com.qiniu.util.Json;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component("qiniuTask")
+public class QiniuOssTask {
+ private QiniuConfiguration config;
+ private UploadManager uploadManager;
+ private String upToken;
+
+ public int amount = 0;
+
+ @Autowired
+ public void setConfig(QiniuConfiguration config) {
+ this.config = config;
+ }
+
+ /**
+ * 无参任务测试
+ */
+ public void ryNoParams()
+ {
+ System.out.println("[实例任务] ==> 执行无参方法,第 " + (++amount) + " 次.");
+ }
+
+ /**
+ * 供定时任务调用的Bean方法
+ */
+ public void testUpload() {
+ getUploadManager();
+ makeToken();
+ DefaultPutRet putRet = uploadFile(null, "d:/time.jpg");
+ System.out.println(putRet.hash);
+ }
+
+ /**
+ * 使用类Bean的上传管理器、upToken上传指定key和路径的文件
+ * @param key key作为上传文件的云存储文件名,如果为null则使用hash作为文件名
+ * @param filePath 上传的文件路径
+ * @return 七牛云上传结果类
+ */
+ public DefaultPutRet uploadFile(String key, String filePath) {
+ return uploadFile(this.uploadManager, this.upToken, key, filePath);
+ }
+
+ /**
+ * 使用指定的UploadManager、upToken、key和filePath上传文件
+ * @param uploadManager 上传管理器
+ * @param token 上传token
+ * @param key key作为上传文件的云存储文件名,如果为null则使用hash作为文件名
+ * @param filePath 上传的文件路径
+ * @return 七牛云上传结果类
+ */
+ public DefaultPutRet uploadFile(UploadManager uploadManager, String token, String key, String filePath) {
+ try {
+ Response response = uploadManager.put(filePath, key, token);
+ String bodyStr = response.bodyString();
+ DefaultPutRet putRet = Json.decode(bodyStr, DefaultPutRet.class);
+ return putRet;
+ } catch (QiniuException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * 获取上传管理器,并保存在类成员中
+ */
+ public UploadManager getUploadManager() {
+ Configuration cfg = new Configuration(Region.huabei());
+ cfg.useHttpsDomains = false;
+ uploadManager = new UploadManager(cfg);
+
+ return uploadManager;
+ }
+
+
+ /**
+ * 获取七牛云上传Token,并保存在类成员中
+ * @return
+ */
+ public String makeToken() {
+ Auth auth = Auth.create(config.getAccessKey(), config.getSecretKey());
+ upToken = auth.uploadToken(config.getBucket());
+
+ return upToken;
+ }
+}
diff --git a/private-farm/src/main/java/com/jlt/csa/task/SimpleFunctionTask.java b/private-farm/src/main/java/com/jlt/csa/task/SimpleFunctionTask.java
new file mode 100644
index 000000000..9e7b99df4
--- /dev/null
+++ b/private-farm/src/main/java/com/jlt/csa/task/SimpleFunctionTask.java
@@ -0,0 +1,9 @@
+package com.jlt.csa.task;
+
+public class SimpleFunctionTask {
+ public static int amount = 0;
+ public void ryNoParams()
+ {
+ System.out.println("[方法任务] ==> 执行无参方法,第 " + (++amount) + " 次.");
+ }
+}
diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml
index ed00cd045..cf1ce2d72 100644
--- a/ruoyi-admin/src/main/resources/application.yml
+++ b/ruoyi-admin/src/main/resources/application.yml
@@ -124,3 +124,13 @@ xss:
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
+
+# 七牛云对象存储
+qiniu:
+ # 是否启用云存储,针对上传
+ enabled: true
+ # 是否读取云存储
+ isUse: false
+ accessKey: 8Qmhci_2fkwFOp2dV74TiVTG2k3IubxOd20X-KJk
+ secretKey: 3DsZ_Oq02QOp2iJbpEKvIFd4Ul3ZBs0tMPXvGUcI
+ bucket: jlt-test
\ No newline at end of file