diff --git a/src/main/java/com/soongsil/CoffeeChat/domain/assignedcoupon/service/AssignedCouponService.java b/src/main/java/com/soongsil/CoffeeChat/domain/assignedcoupon/service/AssignedCouponService.java index f652c17..9a3ff6f 100644 --- a/src/main/java/com/soongsil/CoffeeChat/domain/assignedcoupon/service/AssignedCouponService.java +++ b/src/main/java/com/soongsil/CoffeeChat/domain/assignedcoupon/service/AssignedCouponService.java @@ -71,7 +71,7 @@ public AssignedCouponRegisterResult registerTargets(List generateQr( "EVENT_403_2: 멘티가 아님 | EVENT_403_3: 타인 커피챗 스캔 | EVENT_403_4: 참여 횟수 초과(2회)", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) public ResponseEntity> verifyQr( - @RequestParam String qrToken, Authentication authentication) { - couponService.verifyQrToken(authentication.getName(), qrToken); + @Valid @RequestBody EventVerifyQrRequest request, + Authentication authentication) { + couponService.verifyQrToken(authentication.getName(), request.qrToken()); return ResponseEntity.ok(ApiResponse.onSuccessOK(null)); } @@ -112,11 +116,10 @@ public ResponseEntity> verifyQr( description = "EVENT_503: 동시성 처리 오류", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) public ResponseEntity>> issueCoupon( - @RequestParam String qrToken, - @RequestParam String storePin, + @Valid @RequestBody EventCouponIssueRequest request, Authentication authentication) { String couponNumber = - couponService.verifyPinAndIssueCoupon(authentication.getName(), qrToken, storePin); + couponService.verifyPinAndIssueCoupon(authentication.getName(), request.qrToken(), request.storePin()); return ResponseEntity.ok(ApiResponse.onSuccessOK(Map.of("couponNumber", couponNumber))); } diff --git a/src/main/java/com/soongsil/CoffeeChat/domain/event/dto/EventCouponIssueRequest.java b/src/main/java/com/soongsil/CoffeeChat/domain/event/dto/EventCouponIssueRequest.java new file mode 100644 index 0000000..35a311d --- /dev/null +++ b/src/main/java/com/soongsil/CoffeeChat/domain/event/dto/EventCouponIssueRequest.java @@ -0,0 +1,9 @@ +package com.soongsil.CoffeeChat.domain.event.dto; + +import jakarta.validation.constraints.NotBlank; + +public record EventCouponIssueRequest ( + @NotBlank String qrToken, + @NotBlank String storePin +){ +} diff --git a/src/main/java/com/soongsil/CoffeeChat/domain/event/dto/EventVerifyQrRequest.java b/src/main/java/com/soongsil/CoffeeChat/domain/event/dto/EventVerifyQrRequest.java new file mode 100644 index 0000000..72c21f1 --- /dev/null +++ b/src/main/java/com/soongsil/CoffeeChat/domain/event/dto/EventVerifyQrRequest.java @@ -0,0 +1,8 @@ +package com.soongsil.CoffeeChat.domain.event.dto; + +import jakarta.validation.constraints.NotBlank; + +public record EventVerifyQrRequest( + @NotBlank String qrToken +) { +} diff --git a/src/main/java/com/soongsil/CoffeeChat/domain/event/service/CouponService.java b/src/main/java/com/soongsil/CoffeeChat/domain/event/service/CouponService.java index e33bb1e..1368c8a 100644 --- a/src/main/java/com/soongsil/CoffeeChat/domain/event/service/CouponService.java +++ b/src/main/java/com/soongsil/CoffeeChat/domain/event/service/CouponService.java @@ -190,7 +190,7 @@ public String verifyPinAndIssueCoupon(String username, String qrToken, String in RLock lock = redissonClient.getLock(lockKey); try { - if (!lock.tryLock(3, 3, TimeUnit.SECONDS)) { + if (!lock.tryLock(3, TimeUnit.SECONDS)) { throw new GlobalException(GlobalErrorCode.EVENT_CONCURRENCY_ERROR); } @@ -229,7 +229,7 @@ public String verifyPinAndIssueCoupon(String username, String qrToken, String in } catch (InterruptedException e) { Thread.currentThread().interrupt(); - throw new IllegalStateException("동시성 처리 중 인터럽트가 발생했습니다."); + throw new GlobalException(GlobalErrorCode.EVENT_CONCURRENCY_ERROR); } finally { if (lock.isLocked() && lock.isHeldByCurrentThread()) { lock.unlock();