1.定义限流接口,注入拦截方法
@Inherited
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface RequestTimes {
//单位时间允许访问次数
int count() default 3;
//设置单位时间为1秒钟
long time() default 1;
}
/**
* @description: aop+自定义注解进行处理; 执行顺序 around->before->正文方法->after
* @author:
* @create: 2022-02-21 17:31
*/
@Component
@Aspect
@Slf4j
public class RequestTimesAop {
@Resource
private RedisUtils redisUtils;
// @Pointcut("@annotation(RequestTimes)")
// private void webLog(){
// }
//切面范围
@Pointcut("execution(* com.analysis.tool.platform.web.controller..*.*(..))")
public void WebPointCut() {
}
// 开始环绕
// @Around("webLog()")
@Around("WebPointCut()")
public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
//