deason 6 éve
szülő
commit
febf881853

+ 8 - 0
examcloud-core-print-common/pom.xml

@@ -55,6 +55,14 @@
                 </exclusion>
             </exclusions>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-configuration-processor</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.upyun</groupId>
+            <artifactId>java-sdk</artifactId>
+        </dependency>
         <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>

+ 30 - 0
examcloud-core-print-common/src/main/java/cn/com/qmth/examcloud/core/print/common/upyun/UpYunClient.java

@@ -0,0 +1,30 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-11-01 17:02:06.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.print.common.upyun;
+
+import main.java.com.UpYun;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author: fengdesheng
+ * @since: 2018/11/1
+ */
+@Component
+public class UpYunClient {
+    @Autowired
+    private UpYunProperty upYunProperty;
+
+    public UpYun getInstance() {
+        UpYun upyun = new UpYun(upYunProperty.getBucket(), upYunProperty.getOperator(), upYunProperty.getPsw());
+        upyun.setDebug(true);
+        upyun.setApiDomain(UpYun.ED_AUTO);
+        return upyun;
+    }
+
+}

+ 80 - 0
examcloud-core-print-common/src/main/java/cn/com/qmth/examcloud/core/print/common/upyun/UpYunProperty.java

@@ -0,0 +1,80 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-11-01 16:59:28.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.print.common.upyun;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+import java.io.Serializable;
+
+/**
+ * 又拍云配置信息
+ *
+ * @author: fengdesheng
+ * @since: 2018/11/1
+ */
+@Component
+@ConfigurationProperties(prefix = "upyun", ignoreUnknownFields = false)
+public class UpYunProperty implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private String operator;//账号
+    private String psw;//密码
+    private String bucket;//存储空间名称
+    private String bucketUrl;//存储空间访问前缀
+    private String fileUrl;//文件访问地址前缀
+    private String uploadUrl;//文件存放目录
+
+    public String getOperator() {
+        return operator;
+    }
+
+    public void setOperator(String operator) {
+        this.operator = operator;
+    }
+
+    public String getPsw() {
+        return psw;
+    }
+
+    public void setPsw(String psw) {
+        this.psw = psw;
+    }
+
+    public String getBucket() {
+        return bucket;
+    }
+
+    public void setBucket(String bucket) {
+        this.bucket = bucket;
+    }
+
+    public String getBucketUrl() {
+        return bucketUrl;
+    }
+
+    public void setBucketUrl(String bucketUrl) {
+        this.bucketUrl = bucketUrl;
+    }
+
+    public String getFileUrl() {
+        return fileUrl;
+    }
+
+    public void setFileUrl(String fileUrl) {
+        this.fileUrl = fileUrl;
+    }
+
+    public String getUploadUrl() {
+        return uploadUrl;
+    }
+
+    public void setUploadUrl(String uploadUrl) {
+        this.uploadUrl = uploadUrl;
+    }
+
+}

+ 38 - 0
examcloud-core-print-provider/src/main/java/cn/com/qmth/examcloud/core/print/api/controller/UploadController.java

@@ -0,0 +1,38 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-11-01 16:01:30.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.print.api.controller;
+
+import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
+import cn.com.qmth.examcloud.core.print.common.upyun.UpYunProperty;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 文件上传相关接口
+ *
+ * @author: fengdesheng
+ * @since: 2018/11/01
+ */
+@RestController
+@Api(tags = "文件上传相关接口")
+@RequestMapping("${$rmp.ctrl.print}/upload")
+public class UploadController extends ControllerSupport {
+    @Autowired
+    private UpYunProperty upYunProperty;
+
+    @PostMapping("/upyun/info")
+    @ApiOperation(value = "获取又拍云信息")
+    public UpYunProperty getUpYunInfo() {
+        return upYunProperty;
+    }
+
+}

+ 8 - 1
examcloud-core-print-starter/src/main/resources/application-dev.properties

@@ -13,4 +13,11 @@ spring.redis.host=redis-host
 spring.redis.port=6379
 # spring cloud config
 spring.application.name=EC-CORE-PRINT
-eureka.client.serviceUrl.defaultZone=http://eureka-host:1111/eureka/
+eureka.client.serviceUrl.defaultZone=http://eureka-host:1111/eureka/
+# upyun config
+upyun.operator=examcloud
+upyun.psw=examcloud123456
+upyun.bucket=exam-cloud-test
+upyun.bucketUrl=https://v0.api.upyun.com/exam-cloud-test
+upyun.fileUrl=https://ecs-static.qmth.com.cn
+upyun.uploadUrl=/ecs-print/test/

+ 8 - 1
examcloud-core-print-starter/src/main/resources/application-prod.properties

@@ -13,4 +13,11 @@ spring.redis.host=redis-host
 spring.redis.port=6379
 # spring cloud config
 spring.application.name=EC-CORE-PRINT
-eureka.client.serviceUrl.defaultZone=http://eureka-host:1111/eureka/
+eureka.client.serviceUrl.defaultZone=http://eureka-host:1111/eureka/
+# upyun config
+upyun.operator=examcloud
+upyun.psw=examcloud123456
+upyun.bucket=exam-cloud
+upyun.bucketUrl=https://v0.api.upyun.com/exam-cloud
+upyun.fileUrl=https://ecs-static.qmth.com.cn
+upyun.uploadUrl=/ecs-print/prod/

+ 8 - 1
examcloud-core-print-starter/src/main/resources/application-test.properties

@@ -13,4 +13,11 @@ spring.redis.host=redis-host
 spring.redis.port=6379
 # spring cloud config
 spring.application.name=EC-CORE-PRINT
-eureka.client.serviceUrl.defaultZone=http://eureka-host:1111/eureka/
+eureka.client.serviceUrl.defaultZone=http://eureka-host:1111/eureka/
+# upyun config
+upyun.operator=examcloud
+upyun.psw=examcloud123456
+upyun.bucket=exam-cloud-test
+upyun.bucketUrl=https://v0.api.upyun.com/exam-cloud-test
+upyun.fileUrl=https://ecs-static.qmth.com.cn
+upyun.uploadUrl=/ecs-print/test/

+ 1 - 0
examcloud-core-print-starter/src/main/resources/security-exclusions.conf

@@ -7,6 +7,7 @@
 [][${springfox.documentation.swagger.v2.path:/v2/api-docs}][GET]
 [${server.error.path:${error.path:/error}}][][POST]
 
+[${$rmp.ctrl.print}/upload][/upyun/info][POST]
 [${$rmp.ctrl.print}/printing/project][/list][POST]
 [${$rmp.ctrl.print}/printing/project][/{id}][POST]
 [${$rmp.ctrl.print}/printing/project][/update][POST]

+ 5 - 0
pom.xml

@@ -93,6 +93,11 @@
                 <artifactId>swagger-bootstrap-ui</artifactId>
                 <version>1.8.5</version>
             </dependency>
+            <dependency>
+                <groupId>com.upyun</groupId>
+                <artifactId>java-sdk</artifactId>
+                <version>3.20</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>