24 lines
735 B
Java
24 lines
735 B
Java
package cn.wujiangbo.controller;
|
|
|
|
import cn.wujiangbo.annotation.RateLimit;
|
|
import cn.wujiangbo.result.JSONResult;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
/**
|
|
* <p>测试类</p>
|
|
*
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/test")
|
|
public class TestController {
|
|
|
|
//cycle秒内只能访问count次
|
|
@RateLimit(key= "testLimit:", count = 2, cycle = 2, msg = "同志,不要请求这么快,好吗")
|
|
@GetMapping("/test001")
|
|
public JSONResult test001() {
|
|
System.out.println("成功发送一条短信");
|
|
return JSONResult.success("成功发送一条短信");
|
|
}
|
|
} |