mirror of https://gitee.com/stylefeng/roses
【8.1.9】【安全日志】更新日志记录报错的提示
parent
245ff20526
commit
7e83fc7d4f
|
@ -4,6 +4,7 @@ import cn.hutool.extra.spring.SpringUtil;
|
|||
import cn.stylefeng.roses.kernel.log.api.LoginLogServiceApi;
|
||||
import cn.stylefeng.roses.kernel.log.api.SecurityLogServiceApi;
|
||||
import cn.stylefeng.roses.kernel.log.api.pojo.security.LogSecurityRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
|
@ -15,6 +16,7 @@ import java.util.concurrent.TimeUnit;
|
|||
* @author fengshuonan
|
||||
* @since 2024/7/10 17:25
|
||||
*/
|
||||
@Slf4j
|
||||
public class AsyncLogManager {
|
||||
|
||||
// 异步操作记录日志的线程池
|
||||
|
@ -51,8 +53,12 @@ public class AsyncLogManager {
|
|||
this.executeLog(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
LoginLogServiceApi loginLogServiceApi = SpringUtil.getBean(LoginLogServiceApi.class);
|
||||
loginLogServiceApi.loginFail(account);
|
||||
try {
|
||||
LoginLogServiceApi loginLogServiceApi = SpringUtil.getBean(LoginLogServiceApi.class);
|
||||
loginLogServiceApi.loginFail(account);
|
||||
} catch (Exception e) {
|
||||
log.error("记录登录失败日志异常!", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -67,8 +73,12 @@ public class AsyncLogManager {
|
|||
this.executeLog(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
SecurityLogServiceApi securityLogServiceApi = SpringUtil.getBean(SecurityLogServiceApi.class);
|
||||
securityLogServiceApi.add(logSecurityRequest);
|
||||
try {
|
||||
SecurityLogServiceApi securityLogServiceApi = SpringUtil.getBean(SecurityLogServiceApi.class);
|
||||
securityLogServiceApi.add(logSecurityRequest);
|
||||
} catch (Exception e) {
|
||||
log.error("记录安全日志异常!", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import cn.stylefeng.roses.kernel.log.security.enums.LogSecurityExceptionEnum;
|
|||
import cn.stylefeng.roses.kernel.log.security.mapper.LogSecurityMapper;
|
||||
import cn.stylefeng.roses.kernel.log.security.service.LogSecurityService;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.rule.util.HttpServletUtil;
|
||||
import cn.stylefeng.roses.kernel.security.api.CountValidatorApi;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
@ -40,7 +39,7 @@ public class LogSecurityServiceImpl extends ServiceImpl<LogSecurityMapper, LogSe
|
|||
public void add(LogSecurityRequest logSecurityRequest) {
|
||||
|
||||
// 同一个IP一个小时内不能超过100条,防止刷接口
|
||||
countValidatorApi.countAndValidate(VALIDATE_COUNT_PREFIX + HttpServletUtil.getRequestClientIp(HttpServletUtil.getRequest()),
|
||||
countValidatorApi.countAndValidate(VALIDATE_COUNT_PREFIX + logSecurityRequest.getClientIp(),
|
||||
3600L, 100L);
|
||||
|
||||
LogSecurity logSecurity = new LogSecurity();
|
||||
|
|
Loading…
Reference in New Issue