You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
794 B
42 lines
794 B
|
7 months ago
|
package com.ruoyi.common.annotation;
|
||
|
|
|
||
|
|
import com.ruoyi.common.enums.LimitType;
|
||
|
|
|
||
|
|
import java.lang.annotation.*;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 限流注解
|
||
|
|
*
|
||
|
|
* @author Lion Li
|
||
|
|
*/
|
||
|
|
@Target(ElementType.METHOD)
|
||
|
|
@Retention(RetentionPolicy.RUNTIME)
|
||
|
|
@Documented
|
||
|
|
public @interface RateLimiter {
|
||
|
|
/**
|
||
|
|
* 限流key,支持使用Spring el表达式来动态获取方法上的参数值
|
||
|
|
* 格式类似于 #code.id #{#code}
|
||
|
|
*/
|
||
|
|
String key() default "";
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 限流时间,单位秒
|
||
|
|
*/
|
||
|
|
int time() default 60;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 限流次数
|
||
|
|
*/
|
||
|
|
int count() default 100;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 限流类型
|
||
|
|
*/
|
||
|
|
LimitType limitType() default LimitType.DEFAULT;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 提示消息 支持国际化 格式为 {code}
|
||
|
|
*/
|
||
|
|
String message() default "{rate.limiter.message}";
|
||
|
|
}
|