|
@@ -1,11 +1,15 @@
|
|
|
package com.fdkankan.web.util;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.http.ContentType;
|
|
|
import cn.hutool.http.useragent.UserAgent;
|
|
|
import cn.hutool.http.useragent.UserAgentUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+
|
|
|
+import java.util.Enumeration;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import org.aspectj.lang.JoinPoint;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
@@ -39,6 +43,26 @@ public class WebUtil {
|
|
|
return request.getParameter(paramName);
|
|
|
}
|
|
|
|
|
|
+ public static Map<String, Object> getParameter(JoinPoint pjp, HttpServletRequest request) {
|
|
|
+ Object[] args = pjp.getArgs();
|
|
|
+ String contentType = request.getContentType();
|
|
|
+ if (StrUtil.isNotEmpty(contentType) && contentType.contains(ContentType.JSON.getValue())) {
|
|
|
+ return JSON.parseObject(JSON.toJSONString(args[0]), HashMap.class);
|
|
|
+ } else {
|
|
|
+ Enumeration<String> parameterNames = request.getParameterNames();
|
|
|
+ if(CollUtil.isEmpty(parameterNames)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ String name = null;
|
|
|
+ do {
|
|
|
+ name = parameterNames.nextElement();
|
|
|
+ params.put(name, request.getParameter(name));
|
|
|
+ }while (parameterNames.hasMoreElements());
|
|
|
+ return params;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取客户端请求终端地址
|
|
|
* @param request 客户端请求request
|