update 优化 操作日志密码脱敏
parent
76b247b79b
commit
4c48108625
|
|
@ -1,5 +1,7 @@
|
||||||
package com.ruoyi.common.log.aspect;
|
package com.ruoyi.common.log.aspect;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Dict;
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.utils.JsonUtils;
|
import com.ruoyi.common.core.utils.JsonUtils;
|
||||||
import com.ruoyi.common.core.utils.ServletUtils;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
|
|
@ -35,6 +37,11 @@ import java.util.Map;
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
public class LogAspect {
|
public class LogAspect {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排除敏感属性字段
|
||||||
|
*/
|
||||||
|
public static final String[] EXCLUDE_PROPERTIES = { "password", "oldPassword", "newPassword", "confirmPassword" };
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AsyncLogService asyncLogService;
|
private AsyncLogService asyncLogService;
|
||||||
|
|
||||||
|
|
@ -142,8 +149,15 @@ public class LogAspect {
|
||||||
for (Object o : paramsArray) {
|
for (Object o : paramsArray) {
|
||||||
if (ObjectUtil.isNotNull(o) && !isFilterObject(o)) {
|
if (ObjectUtil.isNotNull(o) && !isFilterObject(o)) {
|
||||||
try {
|
try {
|
||||||
params.append(JsonUtils.toJsonString(o)).append(" ");
|
String str = JsonUtils.toJsonString(o);
|
||||||
|
Dict dict = JsonUtils.parseMap(str);
|
||||||
|
if (MapUtil.isNotEmpty(dict)) {
|
||||||
|
MapUtil.removeAny(dict, EXCLUDE_PROPERTIES);
|
||||||
|
str = JsonUtils.toJsonString(dict);
|
||||||
|
}
|
||||||
|
params.append(str).append(" ");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue