【8.1.9】【sys】更新登录失败的日志,增加客户端ip的参数

dev-8.1.9
stylefeng 2024-07-12 14:10:13 +08:00
parent c63b965e03
commit 49e1e57113
4 changed files with 6 additions and 6 deletions

View File

@ -330,7 +330,7 @@ public class LoginService {
loginErrorCountCacheApi.put(loginRequest.getAccount(), loginErrorCount + 1); loginErrorCountCacheApi.put(loginRequest.getAccount(), loginErrorCount + 1);
// 记录登录失败日志 // 记录登录失败日志
AsyncLogManager.getInstance().recordLoginLogFail(loginRequest.getAccount()); AsyncLogManager.getInstance().recordLoginLogFail(loginRequest.getAccount(), HttpServletUtil.getRequestClientIp(HttpServletUtil.getRequest()));
} }
throw new AuthException(AuthExceptionEnum.USERNAME_PASSWORD_ERROR); throw new AuthException(AuthExceptionEnum.USERNAME_PASSWORD_ERROR);

View File

@ -59,7 +59,7 @@ public interface LoginLogServiceApi {
* @author fengshuonan * @author fengshuonan
* @since 2024/7/10 17:30 * @since 2024/7/10 17:30
*/ */
void loginFail(String account); void loginFail(String account, String ip);
/** /**
* 退 * 退

View File

@ -49,13 +49,13 @@ public class AsyncLogManager {
* @author fengshuonan * @author fengshuonan
* @since 2024/7/10 17:29 * @since 2024/7/10 17:29
*/ */
public void recordLoginLogFail(String account) { public void recordLoginLogFail(String account, String ip) {
this.executeLog(new TimerTask() { this.executeLog(new TimerTask() {
@Override @Override
public void run() { public void run() {
try { try {
LoginLogServiceApi loginLogServiceApi = SpringUtil.getBean(LoginLogServiceApi.class); LoginLogServiceApi loginLogServiceApi = SpringUtil.getBean(LoginLogServiceApi.class);
loginLogServiceApi.loginFail(account); loginLogServiceApi.loginFail(account, ip);
} catch (Exception e) { } catch (Exception e) {
log.error("记录登录失败日志异常!", e); log.error("记录登录失败日志异常!", e);
} }

View File

@ -102,12 +102,12 @@ public class SysLoginLogServiceImpl extends ServiceImpl<SysLoginLogMapper, SysLo
} }
@Override @Override
public void loginFail(String account) { public void loginFail(String account, String ip) {
SysLoginLog sysLoginLog = new SysLoginLog(); SysLoginLog sysLoginLog = new SysLoginLog();
sysLoginLog.setLlgName(LoginLogConstant.LOGIN_IN_LOGINNAME); sysLoginLog.setLlgName(LoginLogConstant.LOGIN_IN_LOGINNAME);
sysLoginLog.setLlgSucceed(LoginLogConstant.OPERATION_FAIL); sysLoginLog.setLlgSucceed(LoginLogConstant.OPERATION_FAIL);
sysLoginLog.setLlgMessage(LoginLogConstant.LOGIN_IN_SUCCESS_FAIL); sysLoginLog.setLlgMessage(LoginLogConstant.LOGIN_IN_SUCCESS_FAIL);
sysLoginLog.setLlgIpAddress(HttpServletUtil.getRequestClientIp(HttpServletUtil.getRequest())); sysLoginLog.setLlgIpAddress(ip);
sysLoginLog.setAccount(account); sysLoginLog.setAccount(account);
this.save(sysLoginLog); this.save(sysLoginLog);
} }