Initial project
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package com.imyeyu.spring.annotation;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 应用在 Controller 的接口上
|
||||
*
|
||||
* <p>{@link #lifeCycle()} 生命周期内(秒)限制访问 {@link #value()} 次
|
||||
*
|
||||
* @author 夜雨
|
||||
* @version 2021-08-16 17:57
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Component
|
||||
public @interface RequestRateLimit {
|
||||
|
||||
/**
|
||||
* 生命周期内访问限制,默认 10 秒内 10 次
|
||||
*
|
||||
* @return 生命周期内限制访问次数
|
||||
*/
|
||||
int value() default 10;
|
||||
|
||||
/**
|
||||
* 生命周期
|
||||
*
|
||||
* @return 生命周期秒数
|
||||
*/
|
||||
int lifeCycle() default 10;
|
||||
}
|
||||
Reference in New Issue
Block a user