RateLimiter.java 794 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package com.ruoyi.common.annotation;
  2. import com.ruoyi.common.enums.LimitType;
  3. import java.lang.annotation.*;
  4. /**
  5. * 限流注解
  6. *
  7. * @author Lion Li
  8. */
  9. @Target(ElementType.METHOD)
  10. @Retention(RetentionPolicy.RUNTIME)
  11. @Documented
  12. public @interface RateLimiter {
  13. /**
  14. * 限流key,支持使用Spring el表达式来动态获取方法上的参数值
  15. * 格式类似于 #code.id #{#code}
  16. */
  17. String key() default "";
  18. /**
  19. * 限流时间,单位秒
  20. */
  21. int time() default 60;
  22. /**
  23. * 限流次数
  24. */
  25. int count() default 100;
  26. /**
  27. * 限流类型
  28. */
  29. LimitType limitType() default LimitType.DEFAULT;
  30. /**
  31. * 提示消息 支持国际化 格式为 {code}
  32. */
  33. String message() default "{rate.limiter.message}";
  34. }