Browse Source

预约进校-生成二维码

dzx 9 months ago
parent
commit
bf00a389f6

+ 20 - 0
src/main/java/com/xjrsoft/common/utils/FileZipUtil.java

@@ -1,9 +1,14 @@
 package com.xjrsoft.common.utils;
 
+import org.springframework.web.multipart.MultipartFile;
+
 import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.List;
 import java.util.Map;
 import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
 import java.util.zip.ZipOutputStream;
 
 /**
@@ -163,4 +168,19 @@ public class FileZipUtil {
         }
         return file.getPath();
     }
+
+    /**
+     * 将MultipartFile转成ZipFile
+     * @param multipartFile
+     * @return
+     * @throws IOException
+     */
+    public static ZipFile convertToZipFile(MultipartFile multipartFile) throws IOException {
+        // 创建临时文件
+        Path tempPath = Files.createTempFile("temp", ".zip");
+        multipartFile.transferTo(tempPath); // 将MultipartFile内容写入临时文件
+
+        // 使用ZipFile读取临时文件
+        return new ZipFile(tempPath.toFile());
+    }
 }

+ 2 - 0
src/main/java/com/xjrsoft/module/personnel/controller/ReservationSchoolController.java

@@ -230,6 +230,8 @@ public class ReservationSchoolController {
                 String base64 = QrCodeUtil.createBase64(url, width, height, margin);
                 peopleVo.setQRCode(base64);
             }
+
+            result.add(peopleVo);
         }
         return RT.ok(result);
     }