From 85ef942e7195abeb71466b7159c3ee30161e1e54 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 07 四月 2026 08:51:01 +0800
Subject: [PATCH] 2026.4.7

---
 src/main/kotlin/cn/flightfeather/supervision/common/utils/FileUtil.kt |   44 ++++++++++++++++++--------------------------
 1 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/utils/FileUtil.kt b/src/main/kotlin/cn/flightfeather/supervision/common/utils/FileUtil.kt
index dc7edd0..f1a87c1 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/common/utils/FileUtil.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/common/utils/FileUtil.kt
@@ -122,6 +122,7 @@
                     fos.write(b, 0, a)
                     a = fis.read(b)
                 }
+
             }
 
         }
@@ -130,7 +131,7 @@
     fun saveFiles(files: Array<MultipartFile>, basePath: String, path: String): List<String> {
         val pathList = mutableListOf<String>()
         files.forEach { file ->
-            val ext = file.resource.file.extension
+            val ext = file.originalFilename?.split(".")?.last()
             val fileName = UUID.randomUUID().toString() + "." + ext
             pathList.add("$path$fileName")
             val absolutePath = "${basePath}/$path/"
@@ -145,30 +146,21 @@
     }
 
     /**
-     * 鎸夌収鍥哄畾瀹藉害鍘嬬缉鍥剧墖鑷砨ase64褰㈠紡
+     * 鎸夌収璺緞寤虹珛鏂囦欢澶癸紝骞惰嚜鍔ㄥ鐞嗛噸澶嶈矾寰�
      */
-//    fun compressImage2(bytes: ByteArray): String {
-//        val length = 1440//鍥剧墖闀胯竟鍥哄畾鍘嬬缉涓�1440鍍忕礌
-//
-//        val input = ByteArrayInputStream(bytes)
-//        val srcImg = ImageIO.read(input)
-//        var srcLong = 0
-//        var srcShort = 0
-//        if (srcImg.width <= srcImg.height) {
-//            srcLong = srcImg.height
-//            srcShort = srcImg.width
-//
-//        } else {
-//
-//        }
-//        val scale = w.toFloat() / srcW
-//        val h = (srcImg.height * scale).toInt()
-//
-//        val buffImg = BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB)
-//        buffImg.graphics.drawImage(srcImg.getScaledInstance(w, h, Image.SCALE_SMOOTH), 0, 0, null)
-//        val out = ByteArrayOutputStream()
-//        ImageIO.write(buffImg, "PNG", out)
-//
-//        return SCHEME_PNG + Base64.getEncoder().encodeToString(out.toByteArray())
-//    }
+    fun mkDirs(basePath: String): File {
+        var file = File(basePath)
+        var i = 1
+        while (file.exists() && i <= 100) {
+            val path = "$basePath($i)"
+            file = File(path)
+            i++
+        }
+        if (file.exists()) {
+            delAllFile(file.absolutePath)
+        } else {
+            file.mkdirs()
+        }
+        return file
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3