解决注preventRepeatSubmit解中的问题

This commit is contained in:
sxu 2024-10-28 14:33:38 +08:00
parent 925f678827
commit e6ab7ce194
1 changed files with 15 additions and 3 deletions

View File

@ -18,6 +18,7 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
@Aspect
@ -46,9 +47,20 @@ public class PreventRepeatSubmitAspect {
//获取请求参数
Object[] args = pjp.getArgs();
String argStr = JSON.toJSONString(args);
//这里替换是为了在redis可视化工具中方便查看
argStr=argStr.replace(":","#");
String argStr = "";
for (int i = 0; i < args.length; i++) {
Object obj = args[i];
try {
if (Objects.nonNull(obj)) {
//这里替换是为了在redis可视化工具中方便查看, argStr=argStr.replace(":","#");
argStr = JSON.toJSONString(obj).replace(":", "#");
}
break;
} catch (Exception e) {
e.printStackTrace();
}
}
// 唯一值没有消息头则使用请求地址
String submitKey = request.getHeader(header).trim();
// 唯一标识指定key + url +参数+token