Search in sources :

Example 1 with AdminLoginRequest

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("日志保存失败");
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) BaseResponse(com.tony.billing.response.BaseResponse) LoginLog(com.tony.billing.entity.LoginLog) AdminLoginRequest(com.tony.billing.request.admin.AdminLoginRequest) AfterReturning(org.aspectj.lang.annotation.AfterReturning)

Aggregations

LoginLog (com.tony.billing.entity.LoginLog)1 AdminLoginRequest (com.tony.billing.request.admin.AdminLoginRequest)1 BaseResponse (com.tony.billing.response.BaseResponse)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 AfterReturning (org.aspectj.lang.annotation.AfterReturning)1