io.springfox
--
Gitee
From d76a53602e25fcaaecdcb79fd22b51ac84596509 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E6=96=87?= <289222346@qq.com>
Date: Fri, 16 Sep 2022 18:18:01 +0800
Subject: [PATCH 4/8] =?UTF-8?q?feat(FileUtil):web.core=E5=AF=B9myjdbc.core?=
=?UTF-8?q?=E7=9A=84=E6=89=A9=E5=85=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../com/myjdbc/web/core/util/FileUtil.java | 42 +++++++++++++++++++
1 file changed, 42 insertions(+)
create mode 100644 src/main/java/com/myjdbc/web/core/util/FileUtil.java
diff --git a/src/main/java/com/myjdbc/web/core/util/FileUtil.java b/src/main/java/com/myjdbc/web/core/util/FileUtil.java
new file mode 100644
index 0000000..63c58d1
--- /dev/null
+++ b/src/main/java/com/myjdbc/web/core/util/FileUtil.java
@@ -0,0 +1,42 @@
+package com.myjdbc.web.core.util;
+
+import com.myjdbc.web.core.model.ResultBody;
+import org.apache.tomcat.util.http.fileupload.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+public class FileUtil extends com.myjdbc.core.util.FileUtil {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(FileUtil.class);
+
+ public ResultBody fileUpload(MultipartFile multipartFile, String pathname) {
+ File file = new File(pathname);
+ FileOutputStream fileOutputStream = null;
+ try {
+ fileOutputStream = new FileOutputStream(file);
+ IOUtils.copy(multipartFile.getInputStream(), fileOutputStream);
+ return ResultUtil.createSuccess();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ return ResultUtil.createError(e.getMessage());
+ } catch (IOException e) {
+ e.printStackTrace();
+ return ResultUtil.createError(e.getMessage());
+ } finally {
+ try {
+ //关闭
+ fileOutputStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ LOGGER.error("文件关闭错误", e);
+ }
+ }
+ }
+
+}
\ No newline at end of file
--
Gitee
From 5ff6bcf4c1f7bf3cba8a718386b3f7c21a13d2be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E6=96=87?= <289222346@qq.com>
Date: Fri, 16 Sep 2022 18:22:25 +0800
Subject: [PATCH 5/8] =?UTF-8?q?refactor(FileUtil):=E4=BC=98=E5=8C=96fileUp?=
=?UTF-8?q?load=E6=96=B9=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../com/myjdbc/web/core/util/FileUtil.java | 26 ++++++++++++-------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/main/java/com/myjdbc/web/core/util/FileUtil.java b/src/main/java/com/myjdbc/web/core/util/FileUtil.java
index 63c58d1..28d7458 100644
--- a/src/main/java/com/myjdbc/web/core/util/FileUtil.java
+++ b/src/main/java/com/myjdbc/web/core/util/FileUtil.java
@@ -1,13 +1,13 @@
package com.myjdbc.web.core.util;
-import com.myjdbc.web.core.model.ResultBody;
+import com.myjdbc.web.core.exception.BusinessException;
+import com.myjdbc.web.core.exception.BusinessExceptionUtil;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -15,19 +15,25 @@ public class FileUtil extends com.myjdbc.core.util.FileUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(FileUtil.class);
- public ResultBody fileUpload(MultipartFile multipartFile, String pathname) {
- File file = new File(pathname);
+ /**
+ * 上传文件
+ *
+ * 将multipartFile文件流存储到服务器本地
+ *
+ * @param multipartFile 文件实体
+ * @param pathName 文件存储路径
+ *
+ * @return
+ */
+ public void fileUpload(MultipartFile multipartFile, String pathName) throws BusinessException {
FileOutputStream fileOutputStream = null;
try {
+ File file = new File(pathName);
fileOutputStream = new FileOutputStream(file);
IOUtils.copy(multipartFile.getInputStream(), fileOutputStream);
- return ResultUtil.createSuccess();
- } catch (FileNotFoundException e) {
+ } catch (Exception e) {
e.printStackTrace();
- return ResultUtil.createError(e.getMessage());
- } catch (IOException e) {
- e.printStackTrace();
- return ResultUtil.createError(e.getMessage());
+ BusinessExceptionUtil.createBusinessException(e.getMessage());
} finally {
try {
//关闭
--
Gitee
From a4582309dc41d9767c35849af70d07242f900060 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E6=96=87?= <289222346@qq.com>
Date: Fri, 16 Sep 2022 18:35:31 +0800
Subject: [PATCH 6/8] =?UTF-8?q?feat(myjdbc):=E6=A1=86=E6=9E=B6=E5=8D=87?=
=?UTF-8?q?=E7=BA=A71.1.2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index f0562f0..6c51c3a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
com.myjdbc
myjdbc-starter-parent
- 1.1.1
+ 1.1.2
com.myjdbc.web
--
Gitee
From 186d1381d8021190bd65bf281a96643def07fe00 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E6=96=87?= <289222346@qq.com>
Date: Fri, 16 Sep 2022 18:58:47 +0800
Subject: [PATCH 7/8] =?UTF-8?q?refactor(FileUtil):fileUpload=E6=94=B9?=
=?UTF-8?q?=E4=B8=BAstatic=E6=96=B9=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/com/myjdbc/web/core/util/FileUtil.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/com/myjdbc/web/core/util/FileUtil.java b/src/main/java/com/myjdbc/web/core/util/FileUtil.java
index 28d7458..11f3323 100644
--- a/src/main/java/com/myjdbc/web/core/util/FileUtil.java
+++ b/src/main/java/com/myjdbc/web/core/util/FileUtil.java
@@ -25,7 +25,7 @@ public class FileUtil extends com.myjdbc.core.util.FileUtil {
*
* @return
*/
- public void fileUpload(MultipartFile multipartFile, String pathName) throws BusinessException {
+ public static void fileUpload(MultipartFile multipartFile, String pathName) throws BusinessException {
FileOutputStream fileOutputStream = null;
try {
File file = new File(pathName);
--
Gitee
From 293c84c8d2180cda367c03270ae1e8c7e651ab0d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E6=96=87?= <289222346@qq.com>
Date: Fri, 16 Sep 2022 19:18:27 +0800
Subject: [PATCH 8/8] =?UTF-8?q?refactor(FileUtil):=E6=B7=BB=E5=8A=A0?=
=?UTF-8?q?=E6=B3=A8=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/com/myjdbc/web/core/util/FileUtil.java | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/main/java/com/myjdbc/web/core/util/FileUtil.java b/src/main/java/com/myjdbc/web/core/util/FileUtil.java
index 11f3323..492656e 100644
--- a/src/main/java/com/myjdbc/web/core/util/FileUtil.java
+++ b/src/main/java/com/myjdbc/web/core/util/FileUtil.java
@@ -11,6 +11,13 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+/**
+ * 文件工具
+ *
+ * @author Chen Wen
+ * @date 19:05 2022/9/16
+ * 本类是对{@link com.myjdbc.core.util.FileUtil } 的继承和扩展
+ */
public class FileUtil extends com.myjdbc.core.util.FileUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(FileUtil.class);
--
Gitee