From 5ca038d888922e93bf45c7bd37f3c6dce849dcff Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期五, 24 十二月 2021 11:36:02 +0800
Subject: [PATCH] update 调整监控依赖 从 common 迁移到 framework

---
 ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java |  200 +++++++++++++++++++++++++++----------------------
 1 files changed, 109 insertions(+), 91 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java
index beaa26c..5babaeb 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java
@@ -3,6 +3,8 @@
 import cn.hutool.core.convert.Convert;
 import cn.hutool.extra.servlet.ServletUtil;
 import cn.hutool.http.HttpStatus;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import org.springframework.http.MediaType;
 import org.springframework.web.context.request.RequestAttributes;
 import org.springframework.web.context.request.RequestContextHolder;
@@ -19,111 +21,127 @@
  *
  * @author ruoyi
  */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
 public class ServletUtils extends ServletUtil {
-	/**
-	 * 鑾峰彇String鍙傛暟
-	 */
-	public static String getParameter(String name) {
-		return getRequest().getParameter(name);
-	}
 
-	/**
-	 * 鑾峰彇String鍙傛暟
-	 */
-	public static String getParameter(String name, String defaultValue) {
-		return Convert.toStr(getRequest().getParameter(name), defaultValue);
-	}
+    /**
+     * 鑾峰彇String鍙傛暟
+     */
+    public static String getParameter(String name) {
+        return getRequest().getParameter(name);
+    }
 
-	/**
-	 * 鑾峰彇Integer鍙傛暟
-	 */
-	public static Integer getParameterToInt(String name) {
-		return Convert.toInt(getRequest().getParameter(name));
-	}
+    /**
+     * 鑾峰彇String鍙傛暟
+     */
+    public static String getParameter(String name, String defaultValue) {
+        return Convert.toStr(getRequest().getParameter(name), defaultValue);
+    }
 
-	/**
-	 * 鑾峰彇Integer鍙傛暟
-	 */
-	public static Integer getParameterToInt(String name, Integer defaultValue) {
-		return Convert.toInt(getRequest().getParameter(name), defaultValue);
-	}
+    /**
+     * 鑾峰彇Integer鍙傛暟
+     */
+    public static Integer getParameterToInt(String name) {
+        return Convert.toInt(getRequest().getParameter(name));
+    }
 
-	/**
-	 * 鑾峰彇request
-	 */
-	public static HttpServletRequest getRequest() {
-		return getRequestAttributes().getRequest();
-	}
+    /**
+     * 鑾峰彇Integer鍙傛暟
+     */
+    public static Integer getParameterToInt(String name, Integer defaultValue) {
+        return Convert.toInt(getRequest().getParameter(name), defaultValue);
+    }
 
-	/**
-	 * 鑾峰彇response
-	 */
-	public static HttpServletResponse getResponse() {
-		return getRequestAttributes().getResponse();
-	}
+    /**
+     * 鑾峰彇Boolean鍙傛暟
+     */
+    public static Boolean getParameterToBool(String name) {
+        return Convert.toBool(getRequest().getParameter(name));
+    }
 
-	/**
-	 * 鑾峰彇session
-	 */
-	public static HttpSession getSession() {
-		return getRequest().getSession();
-	}
+    /**
+     * 鑾峰彇Boolean鍙傛暟
+     */
+    public static Boolean getParameterToBool(String name, Boolean defaultValue) {
+        return Convert.toBool(getRequest().getParameter(name), defaultValue);
+    }
 
-	public static ServletRequestAttributes getRequestAttributes() {
-		RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
-		return (ServletRequestAttributes) attributes;
-	}
+    /**
+     * 鑾峰彇request
+     */
+    public static HttpServletRequest getRequest() {
+        return getRequestAttributes().getRequest();
+    }
 
-	/**
-	 * 灏嗗瓧绗︿覆娓叉煋鍒板鎴风
-	 *
-	 * @param response 娓叉煋瀵硅薄
-	 * @param string   寰呮覆鏌撶殑瀛楃涓�
-	 * @return null
-	 */
-	public static String renderString(HttpServletResponse response, String string) {
-		try {
-			response.setStatus(HttpStatus.HTTP_OK);
-			response.setContentType(MediaType.APPLICATION_JSON_VALUE);
-			response.setCharacterEncoding(StandardCharsets.UTF_8.toString());
-			response.getWriter().print(string);
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
+    /**
+     * 鑾峰彇response
+     */
+    public static HttpServletResponse getResponse() {
+        return getRequestAttributes().getResponse();
+    }
 
-	/**
-	 * 鏄惁鏄疉jax寮傛璇锋眰
-	 *
-	 * @param request
-	 */
-	public static boolean isAjaxRequest(HttpServletRequest request) {
+    /**
+     * 鑾峰彇session
+     */
+    public static HttpSession getSession() {
+        return getRequest().getSession();
+    }
 
-		String accept = request.getHeader("accept");
-		if (accept != null && accept.indexOf("application/json") != -1) {
-			return true;
-		}
+    public static ServletRequestAttributes getRequestAttributes() {
+        RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
+        return (ServletRequestAttributes) attributes;
+    }
 
-		String xRequestedWith = request.getHeader("X-Requested-With");
-		if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1) {
-			return true;
-		}
+    /**
+     * 灏嗗瓧绗︿覆娓叉煋鍒板鎴风
+     *
+     * @param response 娓叉煋瀵硅薄
+     * @param string   寰呮覆鏌撶殑瀛楃涓�
+     * @return null
+     */
+    public static String renderString(HttpServletResponse response, String string) {
+        try {
+            response.setStatus(HttpStatus.HTTP_OK);
+            response.setContentType(MediaType.APPLICATION_JSON_VALUE);
+            response.setCharacterEncoding(StandardCharsets.UTF_8.toString());
+            response.getWriter().print(string);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
 
-		String uri = request.getRequestURI();
-		if (StringUtils.equalsAnyIgnoreCase(uri, ".json", ".xml")) {
-			return true;
-		}
+    /**
+     * 鏄惁鏄疉jax寮傛璇锋眰
+     *
+     * @param request
+     */
+    public static boolean isAjaxRequest(HttpServletRequest request) {
 
-		String ajax = request.getParameter("__ajax");
-		if (StringUtils.equalsAnyIgnoreCase(ajax, "json", "xml")) {
-			return true;
-		}
-		return false;
-	}
+        String accept = request.getHeader("accept");
+        if (accept != null && accept.indexOf("application/json") != -1) {
+            return true;
+        }
 
-	public static String getClientIP() {
-		return getClientIP(getRequest());
-	}
+        String xRequestedWith = request.getHeader("X-Requested-With");
+        if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1) {
+            return true;
+        }
+
+        String uri = request.getRequestURI();
+        if (StringUtils.equalsAnyIgnoreCase(uri, ".json", ".xml")) {
+            return true;
+        }
+
+        String ajax = request.getParameter("__ajax");
+        if (StringUtils.equalsAnyIgnoreCase(ajax, "json", "xml")) {
+            return true;
+        }
+        return false;
+    }
+
+    public static String getClientIP() {
+        return getClientIP(getRequest());
+    }
 
 }

--
Gitblit v1.9.3