From 69e6ce2211b96da8466912a57178f6324cb197ef Mon Sep 17 00:00:00 2001
From: luoyb <412940104@qq.com>
Date: 星期三, 02 六月 2021 20:59:01 +0800
Subject: [PATCH] fix(bug修复): 增加了请假类型查询项
---
febs-common/febs-common-core/src/main/java/cc/mrbird/febs/common/core/utils/MyUtil.java | 33 +++++++++++++++++++++++++++++++--
1 files changed, 31 insertions(+), 2 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 86a0f69..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,9 +117,9 @@
//原本名字
String fileName = file.getOriginalFilename();
String suffix = "";
- if (fileName.indexOf(".") > 0) {
+ if (fileName.lastIndexOf(".") > 0) {
//后缀
- suffix = fileName.substring(fileName.indexOf("."));
+ suffix = fileName.substring(fileName.lastIndexOf("."));
}
//生成新的名字
String newName = nextIdStr + suffix;
@@ -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