Your Name 3 년 전
부모
커밋
7dc020683c

+ 0
- 1
pom.xml 파일 보기

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

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

12
 @Component
12
 @Component
13
 public class HttpUtils {
13
 public class HttpUtils {
14
 
14
 
15
-    public InputStream download(String url) {
15
+    public byte[] download(String url) {
16
         RestTemplate restTemplate = new RestTemplate();
16
         RestTemplate restTemplate = new RestTemplate();
17
         HttpHeaders headers = new HttpHeaders();
17
         HttpHeaders headers = new HttpHeaders();
18
         HttpEntity<String> entity = new HttpEntity<String>(headers);
18
         HttpEntity<String> entity = new HttpEntity<String>(headers);
20
         String formatURL = (String) urlAndParams.get("url");
20
         String formatURL = (String) urlAndParams.get("url");
21
         Map<String, String> params = (Map<String, String>) urlAndParams.get("params");
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
         return resp.getBody();
24
         return resp.getBody();
25
     }
25
     }
26
 
26
 

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

11
 import org.springframework.stereotype.Component;
11
 import org.springframework.stereotype.Component;
12
 
12
 
13
 import javax.servlet.http.HttpServletResponse;
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
 import java.nio.ByteBuffer;
15
 import java.nio.ByteBuffer;
19
 import java.nio.channels.Channels;
16
 import java.nio.channels.Channels;
20
 import java.nio.channels.ReadableByteChannel;
17
 import java.nio.channels.ReadableByteChannel;
46
         for (RFile f : files) {
43
         for (RFile f : files) {
47
             ZipParameters zipParameters = new ZipParameters();
44
             ZipParameters zipParameters = new ZipParameters();
48
             zipParameters.setFileNameInZip(f.getName());
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
             zipFile.addStream(inputStream, zipParameters);
48
             zipFile.addStream(inputStream, zipParameters);
51
             inputStream.close();
49
             inputStream.close();
52
         }
50
         }

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

112
                 ZipUtil.RFile f = new ZipUtil.RFile();
112
                 ZipUtil.RFile f = new ZipUtil.RFile();
113
                 f.setName(item.getCardNo() + ".png");
113
                 f.setName(item.getCardNo() + ".png");
114
                 f.setUrl(item.getQrImage());
114
                 f.setUrl(item.getQrImage());
115
+                files.add(f);
115
             }
116
             }
116
         }
117
         }
117
 
118