use of com.tony.billing.request.admin.AdminLoginRequest in project BillingDubbo by TonyJiangWJ.
the class LoginResultInterceptor method getResult.
@AfterReturning(returning = "returnValue", pointcut = "execution(* com.tony.billing.controller.AdminController.login(..))")
public void getResult(JoinPoint point, Object returnValue) {
Object[] args = point.getArgs();
AdminLoginRequest loginRequest = (AdminLoginRequest) args[0];
HttpServletRequest httpServletRequest = (HttpServletRequest) args[1];
BaseResponse response = (BaseResponse) returnValue;
LoginLog loginLog = new LoginLog();
loginLog.setLoginIp(getLoginIp(httpServletRequest));
if (loginRequest.getUserName() != null) {
loginLog.setUserName(loginRequest.getUserName());
} else {
loginLog.setUserName("未知");
}
loginLog.setLoginResult(JSON.toJSONString(response));
loginLog.setCode(response.getCode());
loginLog.setMsg(response.getMsg());
Long id = loginLogService.addLog(loginLog);
logger.info("{} 请求登录, 结果:{}", loginLog.getUserName(), loginLog.getLoginResult());
logger.info("ip地址:{}", loginLog.getLoginIp());
if (id != null) {
logger.info("日志保存成功,id:{}", id);
} else {
logger.error("日志保存失败");
}
}
Aggregations