fix(操作日志): 登出操作日志记录 #1005204
--bug=1005204 --user=赵勇 【系统设置-操作日志】... https://www.tapd.cn/55049933/s/1027443
This commit is contained in:
parent
423a399779
commit
4114edd3d3
|
@ -64,7 +64,7 @@ public class LoginController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/signout")
|
@GetMapping(value = "/signout")
|
||||||
@MsAuditLog(module = "auth_title", type = OperLogConstants.LOGIN, title = "登出")
|
@MsAuditLog(module = "auth_title", beforeEvent = "#msClass.getUserId(id)",type = OperLogConstants.LOGIN, title = "登出",msClass = SessionUtils.class)
|
||||||
public ResultHolder logout() throws Exception {
|
public ResultHolder logout() throws Exception {
|
||||||
userService.logout();
|
userService.logout();
|
||||||
SecurityUtils.getSubject().logout();
|
SecurityUtils.getSubject().logout();
|
||||||
|
|
|
@ -86,25 +86,26 @@ public class MsLogAspect {
|
||||||
for (int len = 0; len < params.length; len++) {
|
for (int len = 0; len < params.length; len++) {
|
||||||
context.setVariable(params[len], args[len]);
|
context.setVariable(params[len], args[len]);
|
||||||
}
|
}
|
||||||
for (Class clazz : msLog.msClass()) {
|
|
||||||
context.setVariable("msClass", applicationContext.getBean(clazz));
|
|
||||||
}
|
|
||||||
Expression expression = parser.parseExpression(msLog.beforeEvent());
|
|
||||||
String beforeContent = expression.getValue(context, String.class);
|
|
||||||
InvocationHandler invocationHandler = Proxy.getInvocationHandler(msLog);
|
InvocationHandler invocationHandler = Proxy.getInvocationHandler(msLog);
|
||||||
Field value = invocationHandler.getClass().getDeclaredField("memberValues");
|
Field value = invocationHandler.getClass().getDeclaredField("memberValues");
|
||||||
value.setAccessible(true);
|
value.setAccessible(true);
|
||||||
|
boolean isNext = false;
|
||||||
|
for (Class clazz : msLog.msClass()) {
|
||||||
|
if (clazz.getName().equals("io.metersphere.commons.utils.SessionUtils")) {
|
||||||
|
Map<String, Object> memberValues = (Map<String, Object>) value.get(invocationHandler);
|
||||||
|
memberValues.put("operUser", SessionUtils.getUserId());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
context.setVariable("msClass", applicationContext.getBean(clazz));
|
||||||
|
isNext = true;
|
||||||
|
}
|
||||||
|
if (isNext) {
|
||||||
|
Expression expression = parser.parseExpression(msLog.beforeEvent());
|
||||||
|
String beforeContent = expression.getValue(context, String.class);
|
||||||
Map<String, Object> memberValues = (Map<String, Object>) value.get(invocationHandler);
|
Map<String, Object> memberValues = (Map<String, Object>) value.get(invocationHandler);
|
||||||
memberValues.put("beforeValue", beforeContent);
|
memberValues.put("beforeValue", beforeContent);
|
||||||
}
|
}
|
||||||
if (msLog != null && StringUtils.isEmpty(msLog.operUser())) {
|
|
||||||
InvocationHandler invocationHandler = Proxy.getInvocationHandler(msLog);
|
|
||||||
Field value = invocationHandler.getClass().getDeclaredField("memberValues");
|
|
||||||
value.setAccessible(true);
|
|
||||||
Map<String, Object> memberValues = (Map<String, Object>) value.get(invocationHandler);
|
|
||||||
memberValues.put("operUser", SessionUtils.getUserId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error(e.getMessage());
|
LogUtil.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -147,6 +148,9 @@ public class MsLogAspect {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Class clazz : msLog.msClass()) {
|
for (Class clazz : msLog.msClass()) {
|
||||||
|
if (clazz.getName().equals("io.metersphere.commons.utils.SessionUtils")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
context.setVariable("msClass", applicationContext.getBean(clazz));
|
context.setVariable("msClass", applicationContext.getBean(clazz));
|
||||||
}
|
}
|
||||||
// 项目ID 表达式
|
// 项目ID 表达式
|
||||||
|
|
Loading…
Reference in New Issue