|
@ -125,12 +125,13 @@ public class OpenApiRequestCheckAspect { |
|
|
|
|
|
|
|
|
if (Math.abs(now - timestamp) > requestTimeMillSecDiff) { |
|
|
if (Math.abs(now - timestamp) > requestTimeMillSecDiff) { |
|
|
// 只允许1分钟之内的请求,允许服务器之间时差为1分钟
|
|
|
// 只允许1分钟之内的请求,允许服务器之间时差为1分钟
|
|
|
throw new RenException(String.format("请求已过时,允许时差为%s s", requestTimeSecDiff)); |
|
|
throw new RenException(EpmetErrorCode.OPEN_API_REQUEST_EXPIRED.getCode(), |
|
|
|
|
|
String.format("请求已过期,允许时差为%s s", requestTimeSecDiff)); |
|
|
} |
|
|
} |
|
|
String nonce = argMap.get(RequestParamKeys.NONCE); |
|
|
String nonce = argMap.get(RequestParamKeys.NONCE); |
|
|
String nonceInCache = redisUtils.getString(RedisKeys.getOpenApiNonceKey(nonce)); |
|
|
String nonceInCache = redisUtils.getString(RedisKeys.getOpenApiNonceKey(nonce)); |
|
|
if (StringUtils.isNotBlank(nonceInCache)) { |
|
|
if (StringUtils.isNotBlank(nonceInCache)) { |
|
|
throw new RenException("请求重复"); |
|
|
throw new RenException(EpmetErrorCode.OPEN_API_REQUEST_REPEAT.getCode()); |
|
|
} |
|
|
} |
|
|
//将nonce缓存到redis,有效期1分钟
|
|
|
//将nonce缓存到redis,有效期1分钟
|
|
|
redisUtils.set(RedisKeys.getOpenApiNonceKey(nonce), System.currentTimeMillis(), requestTimeSecDiff); |
|
|
redisUtils.set(RedisKeys.getOpenApiNonceKey(nonce), System.currentTimeMillis(), requestTimeSecDiff); |
|
|