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(); + } + } +}