【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.rule.exception.base.ServiceException;
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.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -39,14 +40,18 @@ public class LogSecurityServiceImpl extends ServiceImpl<LogSecurityMapper, LogSe
@Override
public void add(LogSecurityRequest logSecurityRequest) {
try {
// 同一个IP一个小时内不能超过100条防止刷接口
countValidatorApi.countAndValidate(VALIDATE_COUNT_PREFIX + logSecurityRequest.getClientIp(),
3600L, 100L);
// 同一个IP一个小时内不能超过100条防止刷接口
countValidatorApi.countAndValidate(VALIDATE_COUNT_PREFIX + logSecurityRequest.getClientIp(),
3600L, 100L);
LogSecurity logSecurity = new LogSecurity();
BeanUtil.copyProperties(logSecurityRequest, logSecurity);
this.save(logSecurity);
LogSecurity logSecurity = new LogSecurity();
BeanUtil.copyProperties(logSecurityRequest, logSecurity);
this.save(logSecurity);
} catch (CountValidateException e) {
// none
}
}
@Override