Skip to content

Commit

Permalink
keyName 변수 사용
Browse files Browse the repository at this point in the history
  • Loading branch information
dla0510 committed May 27, 2024
1 parent f333bed commit a9dfe9e
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ public Object check(final ProceedingJoinPoint joinPoint) throws Throwable {
String[] args = purchaseToken.split(":");
var email = args[0];
var ticketingId = args[1];
var keyName = "queue::" + ticketingId;

validateUser(email);
validateTokenWithRedis(ticketingId, email);
validateTokenWithRedis(keyName, email);

try {
return joinPoint.proceed();
} catch (Throwable e) {
throw e;
} finally {
redisService.removeZset("queue::" + ticketingId, email);
redisService.removeZset(keyName, email);
}
}

Expand All @@ -76,16 +77,16 @@ private void validateUser(String email) {
}
}

private void validateTokenWithRedis(String ticketingId, String email) {
var results = redisService.getZSetRankAndScore("queue::" + ticketingId, email).orElseThrow(() -> {
log.error("User does not enter queue (email: {}, ticketing_id: {})", email, ticketingId);
private void validateTokenWithRedis(String keyName, String email) {
var results = redisService.getZSetRankAndScore(keyName, email).orElseThrow(() -> {
log.error("User does not enter queue (queue_name: {}, email: {})", keyName, email);
return new UserNotExistInQueueException();
});
var rank = results.getFirst();

if (rank >= 10) {
log.error(
"User is not in purchasing order. (email: \" + email + \", ticketing_id: \" + ticketingId + \")\"");
"User is not in purchasing order. (queue_name: {}, email: {})", keyName, email);
throw new UserNotInOrderException();
}
}
Expand Down

0 comments on commit a9dfe9e

Please sign in to comment.