修复Log注解GET请求记录不到参数问题
parent
f646bfc0f5
commit
a8be0ccb35
|
@ -4,8 +4,11 @@ import java.io.IOException;
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
@ -79,6 +82,34 @@ public class ServletUtils
|
|||
return Convert.toBool(getRequest().getParameter(name), defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得所有请求参数
|
||||
*
|
||||
* @param request 请求对象{@link ServletRequest}
|
||||
* @return Map
|
||||
*/
|
||||
public static Map<String, String[]> getParams(ServletRequest request)
|
||||
{
|
||||
final Map<String, String[]> map = request.getParameterMap();
|
||||
return Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得所有请求参数
|
||||
*
|
||||
* @param request 请求对象{@link ServletRequest}
|
||||
* @return Map
|
||||
*/
|
||||
public static Map<String, String> getParamMap(ServletRequest request)
|
||||
{
|
||||
Map<String, String> params = new HashMap<>();
|
||||
for (Map.Entry<String, String[]> entry : getParams(request).entrySet())
|
||||
{
|
||||
params.put(entry.getKey(), StringUtils.join(entry.getValue(), ","));
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取request
|
||||
*/
|
||||
|
|
|
@ -128,7 +128,7 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @return
|
||||
* @return 错误消息
|
||||
*/
|
||||
public static AjaxResult error()
|
||||
{
|
||||
|
@ -139,7 +139,7 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
* 返回错误消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @return 警告消息
|
||||
* @return 错误消息
|
||||
*/
|
||||
public static AjaxResult error(String msg)
|
||||
{
|
||||
|
@ -151,7 +151,7 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
*
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
* @return 警告消息
|
||||
* @return 错误消息
|
||||
*/
|
||||
public static AjaxResult error(String msg, Object data)
|
||||
{
|
||||
|
@ -163,7 +163,7 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
*
|
||||
* @param code 状态码
|
||||
* @param msg 返回内容
|
||||
* @return 警告消息
|
||||
* @return 错误消息
|
||||
*/
|
||||
public static AjaxResult error(int code, String msg)
|
||||
{
|
||||
|
|
|
@ -102,7 +102,6 @@ public class LogAspect
|
|||
catch (Exception exp)
|
||||
{
|
||||
// 记录本地异常日志
|
||||
log.error("==前置通知异常==");
|
||||
log.error("异常信息:{}", exp.getMessage());
|
||||
exp.printStackTrace();
|
||||
}
|
||||
|
@ -150,6 +149,11 @@ public class LogAspect
|
|||
String params = argsArrayToString(joinPoint.getArgs());
|
||||
operLog.setOperParam(StringUtils.substring(params, 0, 2000));
|
||||
}
|
||||
else
|
||||
{
|
||||
Map<?, ?> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest());
|
||||
operLog.setOperParam(StringUtils.substring(JSON.toJSONString(paramsMap, excludePropertyPreFilter()), 0, 2000));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,7 +43,8 @@ public class XssFilter implements GlobalFilter, Ordered
|
|||
{
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
// xss开关未开启 或 通过nacos关闭,不过滤
|
||||
if(!xss.getEnabled()){
|
||||
if (!xss.getEnabled())
|
||||
{
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
// GET DELETE 不过滤
|
||||
|
|
|
@ -71,11 +71,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
public List<SysDept> buildDeptTree(List<SysDept> depts)
|
||||
{
|
||||
List<SysDept> returnList = new ArrayList<SysDept>();
|
||||
List<Long> tempList = new ArrayList<Long>();
|
||||
for (SysDept dept : depts)
|
||||
{
|
||||
tempList.add(dept.getDeptId());
|
||||
}
|
||||
List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList());
|
||||
for (SysDept dept : depts)
|
||||
{
|
||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||
|
|
|
@ -223,11 +223,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|||
public List<SysMenu> buildMenuTree(List<SysMenu> menus)
|
||||
{
|
||||
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
||||
List<Long> tempList = new ArrayList<Long>();
|
||||
for (SysMenu dept : menus)
|
||||
{
|
||||
tempList.add(dept.getMenuId());
|
||||
}
|
||||
List<Long> tempList = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList());
|
||||
for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext();)
|
||||
{
|
||||
SysMenu menu = (SysMenu) iterator.next();
|
||||
|
|
Loading…
Reference in New Issue