提交唯一标识

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

Binary file not shown.