linpf
2021-12-16 0257400b7c42c8143f32dae8e4bffbe90a890f1f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package api.controller;
 
import api.bean.AccessEntity;
import api.result.Msg;
import api.service.AccessService;
import com.google.common.util.concurrent.RateLimiter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.UUID;
 
/**
 * @program: wog
 * @description:
 * @author: YSS
 * @create: 2020-09-25 14:24
 **/
 
@RestController
@RequestMapping("/access")
public class AccessController {
 
    @Autowired
    private AccessService accessService;
 
    RateLimiter rateLimiter = RateLimiter.create(10);
 
    @RequestMapping(value = "/get",method = RequestMethod.POST)
    public Msg get(@RequestBody AccessEntity accessEntity) {
 
        rateLimiter.acquire(1);
        return accessService.getAccessToken(accessEntity);
    }
}