-
Notifications
You must be signed in to change notification settings - Fork 2
feat: 행사 티켓 정보 조회 api 티켓 개수 필드 추가 - #203 #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughSummary by CodeRabbit릴리스 노트
✏️ Tip: You can customize this high-level summary in your review settings. Walkthrough티켓 판매 완료 상태를 Redis 기반으로 관리하기 위한 기능을 추가합니다. TicketType 응답 DTO에 Changes
Sequence DiagramsequenceDiagram
actor Client
participant TicketService
participant RedisManager
participant Database
Client->>TicketService: 행사 티켓 정보 조회 요청
rect rgb(200, 220, 240)
Note over TicketService,RedisManager: Redis 판매 완료 상태 조회
TicketService->>TicketService: 조회할 티켓 타입 ID 수집
TicketService->>RedisManager: mGet(ticketTypeIds)
RedisManager-->>TicketService: Redis 판매 완료 상태 맵
end
alt Redis 조회 성공
TicketService->>TicketService: 판매 완료 상태 맵 구성
else Redis 실패/오류
rect rgb(255, 240, 220)
Note over TicketService,Database: 폴백: DB에서 여유 개수 조회
TicketService->>Database: 티켓 여유 개수 조회
Database-->>TicketService: 여유 개수 데이터
TicketService->>TicketService: 여유 개수 0 여부로 판매 완료 판단
end
end
TicketService->>TicketService: TicketType DTO 생성<br/>(isTicketSoldOut 포함)
TicketService->>TicketService: 행사 정보 응답 구성
TicketService-->>Client: EventTicketInfoResponse 반환
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 분 Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/main/java/com/permitseoul/permitserver/domain/ticket/api/service/TicketService.java (1)
173-179: 불필요한 연산 가능성이 있습니다.
dbRemainMap은 Redis 장애 시 fallback용으로만 사용되지만, 매번 빌드됩니다. Redis가 정상인 경우(대부분의 경우)에는 불필요한 연산입니다.🔎 지연 초기화 방식 제안
Redis 호출 실패 시에만
dbRemainMap을 생성하도록 수정하면 성능을 최적화할 수 있습니다:- //장애 fallback 시 사용할 DB remain 맵 - final Map<Long, Integer> dbRemainMap = ticketTypeList.stream() - .collect(Collectors.toMap( - TicketType::getTicketTypeId, - TicketType::getRemainTicketCount, - (a, b) -> a // 중복이면 앞 값 유지 - )); - final List<Long> ticketTypeIds = ticketTypeList.stream() .map(TicketType::getTicketTypeId) .distinct() .toList();그리고 catch 블록 내에서:
} catch (RedisConnectionFailureException | RedisSystemException | QueryTimeoutException e) { // Redis 장애일 때만 fallback log.error("[TicketType 개수 정보 조회] Redis 장애로 DB remainTicketCount fallback 처리. ticketType={}, err={}", ticketTypeIds, e.getClass().getSimpleName()); + final Map<Long, Integer> dbRemainMap = ticketTypeList.stream() + .collect(Collectors.toMap( + TicketType::getTicketTypeId, + TicketType::getRemainTicketCount, + (a, b) -> a + )); + final Map<Long, Boolean> fallback = new HashMap<>();
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/main/java/com/permitseoul/permitserver/domain/ticket/api/dto/res/EventTicketInfoResponse.javasrc/main/java/com/permitseoul/permitserver/domain/ticket/api/service/TicketService.javasrc/main/java/com/permitseoul/permitserver/global/redis/RedisManager.javasrc/main/java/com/permitseoul/permitserver/global/response/code/ErrorCode.java
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: sjk4618
Repo: PERMIT-SEOUL/permit-server PR: 48
File: src/main/java/com/permitseoul/permitserver/domain/guest/core/domain/entity/GuestEntity.java:31-37
Timestamp: 2025-07-15T09:37:32.765Z
Learning: sjk4618 prefers to implement factory methods or public constructors for entities when they are actually needed, rather than creating them proactively.
🔇 Additional comments (6)
src/main/java/com/permitseoul/permitserver/global/redis/RedisManager.java (1)
80-88: LGTM!
mGet메서드 구현이 깔끔합니다. null/empty 입력과multiGet반환값 null 케이스를 적절히 처리하고 있습니다.src/main/java/com/permitseoul/permitserver/domain/ticket/api/dto/res/EventTicketInfoResponse.java (1)
16-23: LGTM!
isTicketSoldOut필드가 적절하게 추가되었습니다. 다만, 이 API를 사용하는 클라이언트가 있다면 새 필드 추가에 대한 호환성을 확인해 주세요.src/main/java/com/permitseoul/permitserver/domain/ticket/api/service/TicketService.java (4)
84-89: LGTM!Redis 기반 soldOut 상태 조회 로직이 기존 플로우에 잘 통합되었습니다.
364-380: LGTM!
soldOutByTicketTypeId파라미터가 적절히 전달되고 있습니다.
417-436: LGTM!
getOrDefault(ticketType.getTicketTypeId(), false)를 사용하여 맵에 없는 경우 안전하게false를 반환합니다.
239-241: LGTM!상수를 사용하여 Redis 키를 구성하는 것은 좋은 방식입니다.
| if (redisTicketTypeCountValues == null || redisTicketTypeCountValues.size() != ticketTypeKeys.size()) { | ||
| log.error("[TicketInfo] Redis mGet 결과 크기 불일치. keysSize={}, valuesSize={}", | ||
| ticketTypeKeys.size(), redisTicketTypeCountValues == null ? -1 : redisTicketTypeCountValues.size()); | ||
| throw new PaymentBadRequestException(ErrorCode.INTERNAL_TICKET_TYPE_REDIS_ERROR); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exception 타입과 ErrorCode가 일치하지 않습니다.
PaymentBadRequestException을 사용하고 있지만, INTERNAL_TICKET_TYPE_REDIS_ERROR는 500 에러 코드입니다. 또한, Payment 관련 예외를 Ticket 서비스에서 사용하는 것은 의미적으로 맞지 않습니다.
🔎 개선 방안
Ticket 도메인에 적합한 내부 서버 에러 예외 클래스를 사용하거나, 새로운 예외 타입을 정의하는 것이 좋습니다:
- throw new PaymentBadRequestException(ErrorCode.INTERNAL_TICKET_TYPE_REDIS_ERROR);
+ throw new InternalServerErrorException(ErrorCode.INTERNAL_TICKET_TYPE_REDIS_ERROR);또는 TicketService 전용 예외 클래스가 있다면 해당 클래스를 사용해 주세요.
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In
src/main/java/com/permitseoul/permitserver/domain/ticket/api/service/TicketService.java
around lines 206 to 210, the code throws PaymentBadRequestException while using
ErrorCode.INTERNAL_TICKET_TYPE_REDIS_ERROR (a 500-level internal error) and
using a Payment-specific exception in the Ticket domain; replace the thrown
exception with a ticket-appropriate internal server error exception (e.g., a
TicketInternalServerException or a generic InternalServerException) that maps to
ErrorCode.INTERNAL_TICKET_TYPE_REDIS_ERROR, or create/use an existing
TicketService-specific exception class so the exception type semantically
matches the 500 error code and domain.
| BAD_REQUEST_CANCELED_TICKET(HttpStatus.BAD_REQUEST, 40015, "취소된 ticket 입니다."), | ||
| BAD_REQUEST_MISMATCH_TICKET_TYPE_ROUND(HttpStatus.BAD_REQUEST, 40016, "ticketType의 roundId와 다른 ticketRoundId 입니다."), | ||
| BAD_REQUEST_MISMATCH_LIST_SIZE(HttpStatus.BAD_REQUEST, 40017, "list의 길이가 다릅니다."), | ||
| BAD_REQUEST_REDIS_TICKET_TYPE_MISMATCH(HttpStatus.BAD_REQUEST, 40018, "redis ticket tpye mismatch 에러입니다. "), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
에러 메시지에 오타가 있습니다.
"tpye" → "type"으로 수정이 필요합니다. 또한, 메시지 끝의 불필요한 공백도 제거해 주세요.
🔎 수정 제안
- BAD_REQUEST_REDIS_TICKET_TYPE_MISMATCH(HttpStatus.BAD_REQUEST, 40018, "redis ticket tpye mismatch 에러입니다. "),
+ BAD_REQUEST_REDIS_TICKET_TYPE_MISMATCH(HttpStatus.BAD_REQUEST, 40018, "redis ticket type mismatch 에러입니다."),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| BAD_REQUEST_REDIS_TICKET_TYPE_MISMATCH(HttpStatus.BAD_REQUEST, 40018, "redis ticket tpye mismatch 에러입니다. "), | |
| BAD_REQUEST_REDIS_TICKET_TYPE_MISMATCH(HttpStatus.BAD_REQUEST, 40018, "redis ticket type mismatch 에러입니다."), |
🤖 Prompt for AI Agents
In
src/main/java/com/permitseoul/permitserver/global/response/code/ErrorCode.java
around line 32, fix the typo and trailing space in the enum message: change
"redis ticket tpye mismatch 에러입니다. " to "redis ticket type mismatch 에러입니다." by
correcting "tpye" to "type" and removing the extra space at the end so the
string is clean.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search for BAD_REQUEST_REDIS_TICKET_TYPE_MISMATCH usage
echo "=== Searching for BAD_REQUEST_REDIS_TICKET_TYPE_MISMATCH usage ==="
rg -n "BAD_REQUEST_REDIS_TICKET_TYPE_MISMATCH" --type java
echo ""
echo "=== Searching for INTERNAL_TICKET_TYPE_REDIS_ERROR usage ==="
rg -n "INTERNAL_TICKET_TYPE_REDIS_ERROR" --type java
echo ""
echo "=== Searching for all references to the error code ==="
rg -n "40018" --type javaRepository: PERMIT-SEOUL/permit-server
Length of output: 1970
정의된 에러 코드가 사용되지 않습니다. 제거해 주세요.
BAD_REQUEST_REDIS_TICKET_TYPE_MISMATCH는 정의되었으나 코드베이스 어디에서도 사용되지 않습니다. 실제로는 INTERNAL_TICKET_TYPE_REDIS_ERROR(50015)가 TicketService, AdminTicketService, AdminEventService에서 사용 중입니다. 불필요한 에러 코드 정의이므로 제거하거나, 실제 용도가 있다면 구현을 완료해 주세요.
또한 에러 메시지의 "tpye"은 "type"의 오타입니다.
🤖 Prompt for AI Agents
In
src/main/java/com/permitseoul/permitserver/global/response/code/ErrorCode.java
around line 32, the enum constant BAD_REQUEST_REDIS_TICKET_TYPE_MISMATCH is
unused and contains a typo ("tpye"); either delete this constant from the enum,
or if it was intended to be used, replace the current usages of
INTERNAL_TICKET_TYPE_REDIS_ERROR (50015) in TicketService, AdminTicketService,
and AdminEventService with this constant and correct its message to "redis
ticket type mismatch 에러입니다."; ensure imports/compilation are updated after
removal or replacement.
🔥Pull requests
⛳️ 작업한 브랜치
👷 작업한 내용
🚨 참고 사항