提交唯一标识

master
MKing 2023-10-06 22:04:10 +08:00
parent 5bdf4f85e8
commit 1603b202be
3 changed files with 5 additions and 10 deletions

View File

@ -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();
}
throw new RuntimeException(e);
}finally {
set.remove(format);
}
return "请求成功";
}
}

Binary file not shown.