提交唯一标识
parent
5bdf4f85e8
commit
1603b202be
|
@ -23,25 +23,20 @@ public class TestController {
|
|||
@PostMapping
|
||||
public String post(@RequestHeader("token") String token, @RequestBody String str){
|
||||
String format = String.format(apiTemplate, token, request.getRequestURI(), str);
|
||||
|
||||
log.info("提交唯一标识:{}",format);
|
||||
//用户+请求+内容
|
||||
try {
|
||||
if (set.contains(format)){
|
||||
return "重复提交";
|
||||
}
|
||||
|
||||
set.add(format);
|
||||
log.info("接收到请求:{}",str);
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
return "请求成功";
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Thread.sleep(5000);
|
||||
return "请求成功";
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}finally {
|
||||
set.remove(format);
|
||||
}
|
||||
return "请求成功";
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue