Your Name 3 년 전
부모
커밋
7dc020683c

+ 0
- 1
pom.xml 파일 보기

@@ -208,7 +208,6 @@
208 208
 						<artifactId>spring-boot-maven-plugin</artifactId>
209 209
 						<configuration>
210 210
 							<includeSystemScope>true</includeSystemScope>
211
-							<!-- 以下为减少依赖 -->
212 211
 							<layout>ZIP</layout>
213 212
 							<includes>
214 213
 								<include>

+ 2
- 2
src/main/java/com/njyunzhi/pet_identity/common/HttpUtils.java 파일 보기

@@ -12,7 +12,7 @@ import java.util.*;
12 12
 @Component
13 13
 public class HttpUtils {
14 14
 
15
-    public InputStream download(String url) {
15
+    public byte[] download(String url) {
16 16
         RestTemplate restTemplate = new RestTemplate();
17 17
         HttpHeaders headers = new HttpHeaders();
18 18
         HttpEntity<String> entity = new HttpEntity<String>(headers);
@@ -20,7 +20,7 @@ public class HttpUtils {
20 20
         String formatURL = (String) urlAndParams.get("url");
21 21
         Map<String, String> params = (Map<String, String>) urlAndParams.get("params");
22 22
 
23
-        ResponseEntity<InputStream> resp = restTemplate.exchange(formatURL, HttpMethod.GET, entity, InputStream.class, params);
23
+        ResponseEntity<byte[]> resp = restTemplate.exchange(formatURL, HttpMethod.GET, entity, byte[].class, params);
24 24
         return resp.getBody();
25 25
     }
26 26
 

+ 3
- 5
src/main/java/com/njyunzhi/pet_identity/common/ZipUtil.java 파일 보기

@@ -11,10 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
11 11
 import org.springframework.stereotype.Component;
12 12
 
13 13
 import javax.servlet.http.HttpServletResponse;
14
-import java.io.FileInputStream;
15
-import java.io.IOException;
16
-import java.io.InputStream;
17
-import java.io.OutputStream;
14
+import java.io.*;
18 15
 import java.nio.ByteBuffer;
19 16
 import java.nio.channels.Channels;
20 17
 import java.nio.channels.ReadableByteChannel;
@@ -46,7 +43,8 @@ public class ZipUtil {
46 43
         for (RFile f : files) {
47 44
             ZipParameters zipParameters = new ZipParameters();
48 45
             zipParameters.setFileNameInZip(f.getName());
49
-            InputStream inputStream = httpUtils.download(f.getUrl());
46
+            byte[] data = httpUtils.download(f.getUrl());
47
+            InputStream inputStream = new ByteArrayInputStream(data);
50 48
             zipFile.addStream(inputStream, zipParameters);
51 49
             inputStream.close();
52 50
         }

+ 1
- 0
src/main/java/com/njyunzhi/pet_identity/controller/TaCardNoController.java 파일 보기

@@ -112,6 +112,7 @@ public class TaCardNoController extends BaseController {
112 112
                 ZipUtil.RFile f = new ZipUtil.RFile();
113 113
                 f.setName(item.getCardNo() + ".png");
114 114
                 f.setUrl(item.getQrImage());
115
+                files.add(f);
115 116
             }
116 117
         }
117 118