| | |
| | | import java.util.Collections;
|
| | | import java.util.List;
|
| | | import org.aspectj.lang.JoinPoint;
|
| | | import org.aspectj.lang.Signature;
|
| | | import org.aspectj.lang.annotation.Aspect;
|
| | | import org.aspectj.lang.annotation.Before;
|
| | | import org.aspectj.lang.annotation.Pointcut;
|
| | | import org.aspectj.lang.reflect.MethodSignature;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | |
| | | Long number = redisTemplate.execute(limitScript, keys, count, time);
|
| | | if (StringUtils.isNull(number) || number.intValue() > count)
|
| | | {
|
| | | throw new ServiceException("访问过于频繁,请稍后再试");
|
| | | throw new ServiceException("访问过于频繁,请稍候再试");
|
| | | }
|
| | | log.info("限制请求'{}',当前请求'{}',缓存key'{}'", count, number.intValue(), key);
|
| | | }
|
| | |
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | throw new RuntimeException("服务器限流异常,请稍后再试");
|
| | | throw new RuntimeException("服务器限流异常,请稍候再试");
|
| | | }
|
| | | }
|
| | |
|