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