forked from admin/springboot-demo
feat: Spring Boot示例项目
- 基础Spring Boot配置 - Docker支持
This commit is contained in:
28
src/main/java/com/example/demo/aop/RateLimited.java
Normal file
28
src/main/java/com/example/demo/aop/RateLimited.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.example.demo.aop;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 限流注解 - 自定义注解配合 AOP 使用
|
||||
*
|
||||
* 学习点:
|
||||
* - 自定义注解定义
|
||||
* - @Retention 保留策略
|
||||
* - @Target 目标元素
|
||||
* - 注解 + AOP 实现声明式功能
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@Documented
|
||||
public @interface RateLimited {
|
||||
|
||||
/**
|
||||
* 每分钟最大请求数
|
||||
*/
|
||||
long value() default 100;
|
||||
|
||||
/**
|
||||
* 限流提示消息
|
||||
*/
|
||||
String message() default "请求过于频繁,请稍后再试";
|
||||
}
|
||||
Reference in New Issue
Block a user