【8.3.0】【log】更新次数校验安全日志的记录

master
stylefeng 2024-09-11 11:32:55 +08:00
parent e0bbf345b2
commit 458b6e8703
1 changed files with 11 additions and 6 deletions

View File

@ -14,6 +14,7 @@ import cn.stylefeng.roses.kernel.log.security.mapper.LogSecurityMapper;
import cn.stylefeng.roses.kernel.log.security.service.LogSecurityService; import cn.stylefeng.roses.kernel.log.security.service.LogSecurityService;
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException; import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
import cn.stylefeng.roses.kernel.security.api.CountValidatorApi; import cn.stylefeng.roses.kernel.security.api.CountValidatorApi;
import cn.stylefeng.roses.kernel.security.api.exception.CountValidateException;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -39,7 +40,7 @@ public class LogSecurityServiceImpl extends ServiceImpl<LogSecurityMapper, LogSe
@Override @Override
public void add(LogSecurityRequest logSecurityRequest) { public void add(LogSecurityRequest logSecurityRequest) {
try {
// 同一个IP一个小时内不能超过100条防止刷接口 // 同一个IP一个小时内不能超过100条防止刷接口
countValidatorApi.countAndValidate(VALIDATE_COUNT_PREFIX + logSecurityRequest.getClientIp(), countValidatorApi.countAndValidate(VALIDATE_COUNT_PREFIX + logSecurityRequest.getClientIp(),
3600L, 100L); 3600L, 100L);
@ -47,6 +48,10 @@ public class LogSecurityServiceImpl extends ServiceImpl<LogSecurityMapper, LogSe
LogSecurity logSecurity = new LogSecurity(); LogSecurity logSecurity = new LogSecurity();
BeanUtil.copyProperties(logSecurityRequest, logSecurity); BeanUtil.copyProperties(logSecurityRequest, logSecurity);
this.save(logSecurity); this.save(logSecurity);
} catch (CountValidateException e) {
// none
}
} }
@Override @Override