From 575e10108216d636dce08876c272312e43e53d5c Mon Sep 17 00:00:00 2001 From: zhangsz Date: Wed, 22 Jan 2025 10:40:02 +0800 Subject: [PATCH] feat: file module support i18n message --- .../src/main/resources/i18n/messages.properties | 2 ++ .../src/main/resources/i18n/messages_en_US.properties | 2 ++ .../src/main/resources/i18n/messages_zh_CN.properties | 2 ++ .../src/main/java/org/wfc/file/utils/FileUploadUtils.java | 3 ++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/wfc-common/wfc-common-core/src/main/resources/i18n/messages.properties b/wfc-common/wfc-common-core/src/main/resources/i18n/messages.properties index 58c5ab1..8927baf 100644 --- a/wfc-common/wfc-common-core/src/main/resources/i18n/messages.properties +++ b/wfc-common/wfc-common-core/src/main/resources/i18n/messages.properties @@ -123,6 +123,8 @@ job.cron.not.blank=Cron expression cannot be blank job.cron.length.valid=Cron expression length cannot exceed 255 characters job.execute.success=The scheduled task was executed successfully, the time taken: {0} milliseconds job.execute.spend.time=the time taken: {0} milliseconds +## wfc-file +file.cannot.null=File must not be null or empty ## wfc-common common.operate.success=Operation successful diff --git a/wfc-common/wfc-common-core/src/main/resources/i18n/messages_en_US.properties b/wfc-common/wfc-common-core/src/main/resources/i18n/messages_en_US.properties index 58c5ab1..8927baf 100644 --- a/wfc-common/wfc-common-core/src/main/resources/i18n/messages_en_US.properties +++ b/wfc-common/wfc-common-core/src/main/resources/i18n/messages_en_US.properties @@ -123,6 +123,8 @@ job.cron.not.blank=Cron expression cannot be blank job.cron.length.valid=Cron expression length cannot exceed 255 characters job.execute.success=The scheduled task was executed successfully, the time taken: {0} milliseconds job.execute.spend.time=the time taken: {0} milliseconds +## wfc-file +file.cannot.null=File must not be null or empty ## wfc-common common.operate.success=Operation successful diff --git a/wfc-common/wfc-common-core/src/main/resources/i18n/messages_zh_CN.properties b/wfc-common/wfc-common-core/src/main/resources/i18n/messages_zh_CN.properties index 4b7e2b9..5018f5b 100644 --- a/wfc-common/wfc-common-core/src/main/resources/i18n/messages_zh_CN.properties +++ b/wfc-common/wfc-common-core/src/main/resources/i18n/messages_zh_CN.properties @@ -124,6 +124,8 @@ job.cron.not.blank=Cron表达式不能为空 job.cron.length.valid=Cron执行表达式不能超过255个字符 job.execute.success=定时任务执行成功, 耗时:{0} 毫秒 job.execute.spend.time=总共耗时:{0} 毫秒 +## wfc-file +file.cannot.null=文件不能为空 ## wfc-common common.operate.success=操作成功 diff --git a/wfc-modules/wfc-file/src/main/java/org/wfc/file/utils/FileUploadUtils.java b/wfc-modules/wfc-file/src/main/java/org/wfc/file/utils/FileUploadUtils.java index 902d675..2b0afa5 100644 --- a/wfc-modules/wfc-file/src/main/java/org/wfc/file/utils/FileUploadUtils.java +++ b/wfc-modules/wfc-file/src/main/java/org/wfc/file/utils/FileUploadUtils.java @@ -11,6 +11,7 @@ import org.wfc.common.core.exception.file.FileNameLengthLimitExceededException; import org.wfc.common.core.exception.file.FileSizeLimitExceededException; import org.wfc.common.core.exception.file.InvalidExtensionException; import org.wfc.common.core.utils.DateUtils; +import org.wfc.common.core.utils.MessageUtils; import org.wfc.common.core.utils.StringUtils; import org.wfc.common.core.utils.file.FileTypeUtils; import org.wfc.common.core.utils.file.MimeTypeUtils; @@ -66,7 +67,7 @@ public class FileUploadUtils { throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, InvalidExtensionException { if (file == null || file.isEmpty()) { - throw new IllegalArgumentException("File must not be null or empty"); + throw new IllegalArgumentException(MessageUtils.message("file.cannot.null")); } int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length(); if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) {