From b4bb423421dbb5f859642b90e2b6896bff179667 Mon Sep 17 00:00:00 2001
From: hongawen <83944980@qq.com>
Date: Tue, 5 Nov 2024 10:27:05 +0800
Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
njcn-common/pom.xml | 10 -----
.../java/com/njcn/web}/utils/ExcelUtil.java | 3 +-
.../com/njcn/web/utils/HttpServletUtil.java | 40 +++++++++++++++++++
3 files changed, 41 insertions(+), 12 deletions(-)
rename {njcn-common/src/main/java/com/njcn/common => njcn-springboot/spingboot2.3.12/src/main/java/com/njcn/web}/utils/ExcelUtil.java (97%)
create mode 100644 njcn-springboot/spingboot2.3.12/src/main/java/com/njcn/web/utils/HttpServletUtil.java
diff --git a/njcn-common/pom.xml b/njcn-common/pom.xml
index a3a3deb..68b278a 100644
--- a/njcn-common/pom.xml
+++ b/njcn-common/pom.xml
@@ -110,16 +110,6 @@
-
- com.njcn
- common-core
- 1.0.0
-
-
- com.njcn
- common-web
- 1.0.0
-
cn.afterturn
easypoi-spring-boot-starter
diff --git a/njcn-common/src/main/java/com/njcn/common/utils/ExcelUtil.java b/njcn-springboot/spingboot2.3.12/src/main/java/com/njcn/web/utils/ExcelUtil.java
similarity index 97%
rename from njcn-common/src/main/java/com/njcn/common/utils/ExcelUtil.java
rename to njcn-springboot/spingboot2.3.12/src/main/java/com/njcn/web/utils/ExcelUtil.java
index 3339506..7027652 100644
--- a/njcn-common/src/main/java/com/njcn/common/utils/ExcelUtil.java
+++ b/njcn-springboot/spingboot2.3.12/src/main/java/com/njcn/web/utils/ExcelUtil.java
@@ -1,9 +1,8 @@
-package com.njcn.common.utils;
+package com.njcn.web.utils;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.hutool.core.util.CharsetUtil;
-import com.njcn.web.utils.HttpServletUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
diff --git a/njcn-springboot/spingboot2.3.12/src/main/java/com/njcn/web/utils/HttpServletUtil.java b/njcn-springboot/spingboot2.3.12/src/main/java/com/njcn/web/utils/HttpServletUtil.java
new file mode 100644
index 0000000..7c0b39f
--- /dev/null
+++ b/njcn-springboot/spingboot2.3.12/src/main/java/com/njcn/web/utils/HttpServletUtil.java
@@ -0,0 +1,40 @@
+package com.njcn.web.utils;
+
+import com.njcn.common.pojo.enums.response.CommonResponseEnum;
+import com.njcn.common.pojo.exception.BusinessException;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ * HttpServlet工具类,获取当前request和response
+ *
+ * @author hongawen
+ * @version 1.0.0
+ * @date 2022年04月01日 11:04
+ */
+public class HttpServletUtil {
+
+
+ public static HttpServletRequest getRequest() {
+ ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+ if (requestAttributes == null) {
+ throw new BusinessException(CommonResponseEnum.REQUEST_EMPTY);
+ } else {
+ return requestAttributes.getRequest();
+ }
+ }
+
+
+ public static HttpServletResponse getResponse() {
+ ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+ if (requestAttributes == null) {
+ throw new BusinessException(CommonResponseEnum.REQUEST_EMPTY);
+ } else {
+ return requestAttributes.getResponse();
+ }
+ }
+}