problem description:
basically prevents users from making malicious requests, limits the number of visits per unit time
, and then makes an aop, but I can"t get the return value of the aop method in the controller layer, as follows:
@Pointcut("execution(public * com.mzd.redis_springboot_mybatis_mysql.controller.*.*(..))")
public void WebPointCut() {
}
@Before("WebPointCut() && @annotation(times)")
public boolean ifovertimes(final JoinPoint joinPoint, RequestTimes times) {
try {
Object[] objects = joinPoint.getArgs();
HttpServletRequest request = null;
for (int i = 0; i < objects.length; iPP) {
if (objects[i] instanceof HttpServletRequest) {
request = (HttpServletRequest) objects[i];
break;
}
}
if (request == null) {
return true;
}
String ip = request.getRemoteAddr();
String url = request.getRequestURL().toString();
String key = "ifovertimes".concat(url).concat(ip);
long count = redisTemplate.opsForValue().increment(key, 1);
//
if (count == 1) {
redisTemplate.expire(key, times.time(), TimeUnit.MILLISECONDS);
}
if (count <= times.count()) {
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
then I want to know how to get this Boolean value in the controller layer, whether it has reached the upper limit of the number of visits or has not reached the upper limit of the number of visits