Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public AssignedCouponRegisterResult registerTargets(List<AssignedCouponTargetReq
}

String phoneNum = normalizePhoneNum(target.phoneNum());
String name = target.name();
String name = target.name() != null ? target.name().trim() : null;

// name, phoneNum blank 검증
if (phoneNum == null
Expand All @@ -96,7 +96,7 @@ public AssignedCouponRegisterResult registerTargets(List<AssignedCouponTargetReq
.putAll(
targetKey,
Map.of(
"name", target.name(),
"name", name,
"status", "TARGETED",
"registeredAt", LocalDateTime.now().toString()));
newCount++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import java.util.Map;

import com.soongsil.CoffeeChat.domain.event.dto.EventCouponIssueRequest;
import com.soongsil.CoffeeChat.domain.event.dto.EventVerifyQrRequest;
import jakarta.validation.Valid;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
Expand Down Expand Up @@ -82,8 +85,9 @@ public ResponseEntity<byte[]> generateQr(
"EVENT_403_2: λ©˜ν‹°κ°€ μ•„λ‹˜ | EVENT_403_3: 타인 컀피챗 μŠ€μΊ” | EVENT_403_4: μ°Έμ—¬ 횟수 초과(2회)",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
public ResponseEntity<ApiResponse<Void>> 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));
}

Expand Down Expand Up @@ -112,11 +116,10 @@ public ResponseEntity<ApiResponse<Void>> verifyQr(
description = "EVENT_503: λ™μ‹œμ„± 처리 였λ₯˜",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
public ResponseEntity<ApiResponse<Map<String, String>>> 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)));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
){
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.soongsil.CoffeeChat.domain.event.dto;

import jakarta.validation.constraints.NotBlank;

public record EventVerifyQrRequest(
@NotBlank String qrToken
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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();
Expand Down
Loading