From 2211a75704860d9e6ae9dd02602746b14ad1e67f Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 17 Jul 2020 09:24:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E7=A0=81=E6=96=87=E4=BB=B6=E5=90=8D?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BAuuid=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/utils/file/FileUploadUtils.java | 16 ++-------------- .../utils/{security => sign}/Md5Utils.java | 2 +- .../system/service/impl/SysUserServiceImpl.java | 1 - 3 files changed, 3 insertions(+), 16 deletions(-) rename ruoyi/src/main/java/com/ruoyi/common/utils/{security => sign}/Md5Utils.java (93%) diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java index 6921fea7..5b356e29 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java +++ b/ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java @@ -9,8 +9,8 @@ import com.ruoyi.common.exception.file.FileNameLengthLimitExceededException; import com.ruoyi.common.exception.file.FileSizeLimitExceededException; import com.ruoyi.common.exception.file.InvalidExtensionException; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.IdUtils; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.security.Md5Utils; import com.ruoyi.framework.config.RuoYiConfig; /** @@ -35,8 +35,6 @@ public class FileUploadUtils */ private static String defaultBaseDir = RuoYiConfig.getProfile(); - private static int counter = 0; - public static void setDefaultBaseDir(String defaultBaseDir) { FileUploadUtils.defaultBaseDir = defaultBaseDir; @@ -125,7 +123,7 @@ public class FileUploadUtils { String fileName = file.getOriginalFilename(); String extension = getExtension(file); - fileName = DateUtils.datePath() + "/" + encodingFilename(fileName) + "." + extension; + fileName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension; return fileName; } @@ -152,16 +150,6 @@ public class FileUploadUtils return pathFileName; } - /** - * 编码文件名 - */ - private static final String encodingFilename(String fileName) - { - fileName = fileName.replace("_", " "); - fileName = Md5Utils.hash(fileName + System.nanoTime() + counter++); - return fileName; - } - /** * 文件大小校验 * diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/security/Md5Utils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/sign/Md5Utils.java similarity index 93% rename from ruoyi/src/main/java/com/ruoyi/common/utils/security/Md5Utils.java rename to ruoyi/src/main/java/com/ruoyi/common/utils/sign/Md5Utils.java index 40e80304..df1e23f8 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/security/Md5Utils.java +++ b/ruoyi/src/main/java/com/ruoyi/common/utils/sign/Md5Utils.java @@ -1,4 +1,4 @@ -package com.ruoyi.common.utils.security; +package com.ruoyi.common.utils.sign; import java.security.MessageDigest; import org.slf4j.Logger; diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysUserServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysUserServiceImpl.java index 28788e4d..b6842e9c 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysUserServiceImpl.java @@ -454,5 +454,4 @@ public class SysUserServiceImpl implements ISysUserService } return successMsg.toString(); } - }