refactor(common): 优化文件大小限制的错误提示信息

- 使用 Hutool 的 FileUtil 类将文件大小转换为更易读的格式
- 更新 README 中的 ContiNew Starter 版本号至 2.9.0
This commit is contained in:
2025-03-06 21:00:37 +08:00
parent d83fd0d5cb
commit b6f01bc2d0
2 changed files with 5 additions and 3 deletions

View File

@@ -16,6 +16,7 @@
package top.continew.admin.common.config.exception;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.text.CharSequenceUtil;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
@@ -94,7 +95,8 @@ public class GlobalExceptionHandler {
} else {
return defaultFail;
}
return R.fail(String.valueOf(HttpStatus.BAD_REQUEST.value()), "请上传小于 %s MB 的文件".formatted(Long.parseLong(sizeLimit) / 1024 / 1024));
return R.fail(String.valueOf(HttpStatus.BAD_REQUEST.value()), "请上传小于 %s 的文件".formatted(FileUtil
.readableFileSize(Long.parseLong(sizeLimit))));
}
/**