张延森 před 5 roky
rodič
revize
be1405007e

+ 1
- 6
foyo-service/pom.xml Zobrazit soubor

@@ -10,7 +10,7 @@
10 10
 	</parent>
11 11
 	<groupId>com.huiju</groupId>
12 12
 	<artifactId>foyo</artifactId>
13
-	<version>0.0.1-SNAPSHOT</version>
13
+	<version>v0.1.0</version>
14 14
 	<name>foyo</name>
15 15
 	<description>Demo project for Spring Boot</description>
16 16
 
@@ -51,11 +51,6 @@
51 51
 			<version>1.2.56</version>
52 52
 			<scope>compile</scope>
53 53
 		</dependency>
54
-		<dependency>
55
-			<groupId>com.aliyun.oss</groupId>
56
-			<artifactId>aliyun-sdk-oss</artifactId>
57
-			<version>2.8.3</version>
58
-		</dependency>
59 54
 
60 55
 		<dependency>
61 56
 			<groupId>com.github.pagehelper</groupId>

+ 19
- 23
foyo-service/src/main/java/com/huiju/foyo/service/impl/ImageServiceimpl.java Zobrazit soubor

@@ -1,11 +1,12 @@
1 1
 package com.huiju.foyo.service.impl;
2 2
 
3
-import com.aliyun.oss.OSSClient;
4 3
 import com.huiju.foyo.service.ImageServiceI;
4
+import org.springframework.beans.factory.annotation.Value;
5 5
 import org.springframework.stereotype.Service;
6 6
 import org.springframework.web.multipart.MultipartFile;
7 7
 
8 8
 import java.io.ByteArrayInputStream;
9
+import java.io.File;
9 10
 import java.io.IOException;
10 11
 import java.util.Date;
11 12
 
@@ -17,30 +18,25 @@ import java.util.Date;
17 18
  */
18 19
 @Service("ImageService")
19 20
 public class ImageServiceimpl implements ImageServiceI {
20
-
21
-    private static String endpoint = "http://oss-cn-shanghai.aliyuncs.com";
22
-    private static String accessKeyId = "LTAIkc75dpkJw8Lb";
23
-    private static String accessKeySecret = "v4bvXCaix6vSDTCFfwSAdqV53iFEQw";
24
-    private static String bucketName = "jingcheng-h5temp";
25
-
21
+    @Value("${assets.images}")
22
+    String imagePath;
23
+    
26 24
     @Override
27 25
     public String getImageUrl(MultipartFile uploadFile) throws IOException {
28
-
26
+        //保存的文件名
29 27
         String imgName = System.currentTimeMillis() + ".png";
30
-        // 创建OSSClient实例
31
-        OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
32
-        // 上传
33
-        long time = System.currentTimeMillis();
34
-
35
-        ossClient.putObject(bucketName, imgName, new ByteArrayInputStream(uploadFile.getBytes()));
36
-
37
-        // 关闭client
38
-        ossClient.shutdown();
39
-        Date expiration = new Date(time + 3600 * 1000 * 24 * 365 * 10);
40
-        String url = ossClient.generatePresignedUrl(bucketName, imgName, expiration).toString();
41
-
42
-        // 截取掉签名
43
-        url = url.substring(0, url.lastIndexOf("&Signature"));
44
-        return url;
28
+        //保存路径
29
+        String path = imagePath + imgName;
30
+        String rebackPath = "uploadimage/" + imgName;
31
+        //生成保存文件
32
+        File troUploadFile = new File(path);
33
+        //将上传文件保存到路径
34
+        try {
35
+            uploadFile.transferTo(troUploadFile);
36
+        } catch (IOException e) {
37
+            e.printStackTrace();
38
+        }
39
+        
40
+        return rebackPath;
45 41
     }
46 42
 }

+ 5
- 0
foyo-service/src/main/resources/application.yml Zobrazit soubor

@@ -13,5 +13,10 @@ mybatis-plus:
13 13
   configuration:
14 14
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
15 15
   mapper-locations: classpath:mapper/*.xml
16
+
16 17
 server:
17 18
   port: 8080
19
+
20
+assets:
21
+  images: /opt/www/upload/images/
22
+

+ 1
- 1
vue-element-admin/config/index.js Zobrazit soubor

@@ -60,7 +60,7 @@ module.exports = {
60 60
      * then assetsPublicPath should be set to "/bar/".
61 61
      * In most cases please use '/' !!!
62 62
      */
63
-    assetsPublicPath: '/',
63
+    assetsPublicPath: './',
64 64
 
65 65
     /**
66 66
      * Source Maps

+ 1
- 1
vue-element-admin/config/prod.env.js Zobrazit soubor

@@ -1,5 +1,5 @@
1 1
 module.exports = {
2 2
   NODE_ENV: '"production"',
3 3
   ENV_CONFIG: '"prod"',
4
-  BASE_API: '"https://api-prod"'
4
+  BASE_API: '"/api/admin/"'
5 5
 }

+ 2
- 1
vue-element-admin/src/views/carousel/edit.vue Zobrazit soubor

@@ -12,6 +12,7 @@
12 12
           :action= "uploadImgUrl"
13 13
           :show-file-list="false"
14 14
           :on-success="handleAvatarSuccess"
15
+          :with-credentials="true"
15 16
           class="avatar-uploader"
16 17
           name="uploadFiles">
17 18
           <img v-if="imageUrl" :src="imageUrl" class="avatar">
@@ -83,7 +84,7 @@ export default {
83 84
         sort: '',
84 85
         imageUrl: ''
85 86
       },
86
-      uploadImgUrl: process.env.BASE_API + '/uploadimage',
87
+      uploadImgUrl: process.env.BASE_API + 'uploadimage',
87 88
       dialogStatus: '',
88 89
       downloadLoading: false,
89 90
       formLabelWidth: '120px',

+ 1
- 1
vue-element-admin/src/views/case/CoverMovement.vue Zobrazit soubor

@@ -78,7 +78,7 @@ export default {
78 78
         labelList: [],
79 79
         type: 'movement'
80 80
       },
81
-      uploadImgUrl: process.env.BASE_API + '/uploadimage',
81
+      uploadImgUrl: process.env.BASE_API + 'uploadimage',
82 82
       dialogStatus: '',
83 83
       downloadLoading: false,
84 84
       formLabelWidth: '120px',

+ 1
- 1
vue-element-admin/src/views/case/add.vue Zobrazit soubor

@@ -131,7 +131,7 @@ export default {
131 131
         content: '',
132 132
         type: 'case'
133 133
       },
134
-      uploadImgUrl: process.env.BASE_API + '/uploadimage',
134
+      uploadImgUrl: process.env.BASE_API + 'uploadimage',
135 135
       dialogStatus: '',
136 136
       downloadLoading: false,
137 137
       formLabelWidth: '120px',

+ 2
- 1
vue-element-admin/src/views/case/cover.vue Zobrazit soubor

@@ -6,6 +6,7 @@
6 6
           :action= "uploadImgUrl"
7 7
           :show-file-list="false"
8 8
           :on-success="handleAvatarSuccess"
9
+          :with-credentials="true"
9 10
           class="avatar-uploader"
10 11
           name="uploadFiles">
11 12
           <img v-if="imageUrl" :src="imageUrl" class="avatar">
@@ -78,7 +79,7 @@ export default {
78 79
         labelList: [],
79 80
         type: 'case'
80 81
       },
81
-      uploadImgUrl: process.env.BASE_API + '/uploadimage',
82
+      uploadImgUrl: process.env.BASE_API + 'uploadimage',
82 83
       dialogStatus: '',
83 84
       downloadLoading: false,
84 85
       formLabelWidth: '120px',

+ 1
- 1
vue-element-admin/src/views/case/edit.vue Zobrazit soubor

@@ -131,7 +131,7 @@ export default {
131 131
         content: '',
132 132
         type: 'case'
133 133
       },
134
-      uploadImgUrl: process.env.BASE_API + '/uploadimage',
134
+      uploadImgUrl: process.env.BASE_API + 'uploadimage',
135 135
       dialogStatus: '',
136 136
       downloadLoading: false,
137 137
       formLabelWidth: '120px',

+ 1
- 1
vue-element-admin/src/views/case/servicecase/add.vue Zobrazit soubor

@@ -101,7 +101,7 @@ export default {
101 101
         serviceImageUrl: '',
102 102
         labelList: []
103 103
       },
104
-      uploadImgUrl: process.env.BASE_API + '/uploadimage',
104
+      uploadImgUrl: process.env.BASE_API + 'uploadimage',
105 105
       dialogStatus: '',
106 106
       downloadLoading: false,
107 107
       formLabelWidth: '120px',

+ 1
- 1
vue-element-admin/src/views/company/edit.vue Zobrazit soubor

@@ -75,7 +75,7 @@ export default {
75 75
         sort: '',
76 76
         companyImg: ''
77 77
       },
78
-      uploadImgUrl: process.env.BASE_API + '/uploadimage',
78
+      uploadImgUrl: process.env.BASE_API + 'uploadimage',
79 79
       dialogStatus: '',
80 80
       downloadLoading: false,
81 81
       formLabelWidth: '120px',

+ 1
- 1
vue-element-admin/src/views/partner/add.vue Zobrazit soubor

@@ -83,7 +83,7 @@ export default {
83 83
         sort: '',
84 84
         logoImg: ''
85 85
       },
86
-      uploadImgUrl: process.env.BASE_API + '/uploadimage',
86
+      uploadImgUrl: process.env.BASE_API + 'uploadimage',
87 87
       dialogStatus: '',
88 88
       downloadLoading: false,
89 89
       formLabelWidth: '120px',

+ 1
- 1
vue-element-admin/src/views/service/edit.vue Zobrazit soubor

@@ -103,7 +103,7 @@ export default {
103 103
         serviceImageUrl: '',
104 104
         labelList: []
105 105
       },
106
-      uploadImgUrl: process.env.BASE_API + '/uploadimage',
106
+      uploadImgUrl: process.env.BASE_API + 'uploadimage',
107 107
       dialogStatus: '',
108 108
       downloadLoading: false,
109 109
       formLabelWidth: '120px',