From 4fd6fc409a6527b13932d45f061a12579763e961 Mon Sep 17 00:00:00 2001
From: luoyb <412940104@qq.com>
Date: 星期日, 07 四月 2024 19:49:40 +0800
Subject: [PATCH] fix: 问题修复 1.备注板块打开时提示绑定错误 2.合同板块不能保存问题

---
 febs-common/febs-common-core/src/main/java/cc/mrbird/febs/common/core/utils/MyUtil.java |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/febs-common/febs-common-core/src/main/java/cc/mrbird/febs/common/core/utils/MyUtil.java b/febs-common/febs-common-core/src/main/java/cc/mrbird/febs/common/core/utils/MyUtil.java
index 4f28ea3..9656734 100644
--- a/febs-common/febs-common-core/src/main/java/cc/mrbird/febs/common/core/utils/MyUtil.java
+++ b/febs-common/febs-common-core/src/main/java/cc/mrbird/febs/common/core/utils/MyUtil.java
@@ -117,7 +117,7 @@
         //原本名字
         String fileName = file.getOriginalFilename();
         String suffix = "";
-        if (fileName.indexOf(".") > 0) {
+        if (fileName.lastIndexOf(".") > 0) {
             //后缀
             suffix = fileName.substring(fileName.lastIndexOf("."));
         }
@@ -128,6 +128,35 @@
         return Dict.create().set("fileName",fileName).set("suffix",suffix).set("newName",newName);
     }
 
+    public static Dict filesUpload(MultipartFile file, String uploadPpath) throws FebsException, IOException {
+        if (file.isEmpty()) {
+            throw new FebsException("上传的文件不能为空!请重新上传");
+        }
+        if (file.getSize() <= 0) {
+            throw new FebsException("上传的文件大小需要大于0kb");
+        }
+        if (file.getSize() > 200 * 1024* 1024) {
+            throw new FebsException("上传的文件大于200M");
+        }
+        if (!FileUtil.exist(uploadPpath)) {
+            FileUtil.mkdir(uploadPpath);
+        }
+        //原本名字
+        String fileName = file.getOriginalFilename();
+        String suffix = "";
+        if (fileName.lastIndexOf(".") > 0) {
+            //后缀
+            suffix = fileName.substring(fileName.lastIndexOf("."));
+        }
+        if(FileUtil.exist(uploadPpath + fileName)){
+            throw  new FebsException("文件已经存在");
+        }
+
+        //上传
+        file.transferTo(new File(uploadPpath + fileName));
+        return Dict.create().set("fileName",fileName).set("suffix",suffix);
+    }
+
     /**
      *      对字节数组字符串进行Base64解码并生成图片
       */

--
Gitblit v1.8.0