-
Notifications
You must be signed in to change notification settings - Fork 0
feat(Order,Reservation): redis 적용 #122
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
Merged
The head ref may contain hidden characters: "feature/#121-\uC0AC\uC6A9\uC790\uC8FC\uC810\uC608\uC57D\uAE30\uB2A5\uAC1C\uC120"
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...src/main/java/com/nowait/applicationuser/order/dto/OrderItemGroupByStatusResponseDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package com.nowait.applicationuser.order.dto; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import com.nowait.domaincorerdb.order.entity.OrderStatus; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class OrderItemGroupByStatusResponseDto { | ||
| private OrderStatus status; | ||
| private List<OrderItemListGetResponseDto> items; | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...user-api/src/main/java/com/nowait/applicationuser/reservation/dto/WaitingResponseDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.nowait.applicationuser.reservation.dto; | ||
|
|
||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| public class WaitingResponseDto { | ||
| private final int rank; | ||
| private final boolean reserved; // true면 예약, false면 대기 | ||
| private final int partySize; | ||
| } |
52 changes: 52 additions & 0 deletions
52
...c/main/java/com/nowait/applicationuser/reservation/repository/WaitingRedisRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package com.nowait.applicationuser.reservation.repository; | ||
|
|
||
|
|
||
| import java.util.Set; | ||
| import org.springframework.data.redis.core.StringRedisTemplate; | ||
| import org.springframework.stereotype.Repository; | ||
| import com.nowait.domaincoreredis.common.util.RedisKeyUtils; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Repository | ||
| @RequiredArgsConstructor | ||
| public class WaitingRedisRepository { | ||
| private final StringRedisTemplate redisTemplate; | ||
|
|
||
| // 중복 등록 방지: 이미 있으면 추가X | ||
| public boolean addToWaitingQueue(Long storeId, String userId, Integer partySize, long timestamp) { | ||
| String queueKey = RedisKeyUtils.buildWaitingKeyPrefix() + storeId; | ||
| String partyKey = RedisKeyUtils.buildWaitingPartySizeKeyPrefix() + storeId; | ||
|
|
||
| Boolean added = redisTemplate.opsForZSet().addIfAbsent(queueKey, userId, timestamp); | ||
| if (Boolean.TRUE.equals(added)) { | ||
| redisTemplate.opsForHash().put(partyKey, userId, partySize.toString()); | ||
| } | ||
| return Boolean.TRUE.equals(added); | ||
| } | ||
|
|
||
| public Integer getPartySize(Long storeId, String userId) { | ||
| String partyKey = RedisKeyUtils.buildWaitingPartySizeKeyPrefix() + storeId; | ||
| Object value = redisTemplate.opsForHash().get(partyKey, userId); | ||
| return value == null ? null : Integer.valueOf(value.toString()); | ||
| } | ||
|
|
||
| public Long getRank(Long storeId, String userId) { | ||
| String key = RedisKeyUtils.buildWaitingKeyPrefix() + storeId; | ||
| return redisTemplate.opsForZSet().rank(key, userId); | ||
| } | ||
|
|
||
| public Long getWaitingCount(Long storeId) { | ||
| String key = RedisKeyUtils.buildWaitingKeyPrefix() + storeId; | ||
| return redisTemplate.opsForZSet().zCard(key); | ||
| } | ||
|
|
||
| public boolean removeWaiting(Long storeId, String userId) { | ||
| String key = RedisKeyUtils.buildWaitingKeyPrefix() + storeId; | ||
| String partyKey = RedisKeyUtils.buildWaitingPartySizeKeyPrefix() + storeId; | ||
| redisTemplate.opsForZSet().remove(key, userId); | ||
| redisTemplate.opsForHash().delete(partyKey, userId); | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
💡 Verification agent
🧩 Analysis chain
OrderItemListGetResponseDto.fromEntity 메서드의 status 필드 설정을 확인해야 합니다.
관련 코드 스니펫에 따르면
fromEntity메서드가status파라미터를 받지만 실제로는status필드를 설정하지 않는 것으로 보입니다. 이후 104번 줄에서getStatus()를 호출하면 null이 반환되어 그룹화 로직이 올바르게 작동하지 않을 수 있습니다.다음 스크립트를 실행하여
fromEntity메서드 구현을 확인해 주세요:🏁 Script executed:
Length of output: 93
다음 스크립트로 DTO 클래스 위치와
fromEntity메서드 구현을 다시 확인해 주세요.🏁 Script executed:
Length of output: 102188
OrderItemListGetResponseDto.fromEntity에 status가 설정되지 않습니다
fromEntity 메서드가 전달받은 status 파라미터를 빌더에 반영하지 않아, getStatus()가 null을 반환해 그룹화 로직이 올바르게 동작하지 않습니다.
수정이 필요한 위치:
fromEntity메서드의 빌더 체인에.status(status)를 추가해야 합니다.예시 수정(diff):
public static OrderItemListGetResponseDto fromEntity(OrderItem orderItem, OrderStatus status) { return OrderItemListGetResponseDto.builder() .orderId(orderItem.getUserOrder().getId()) .menuName(orderItem.getMenu().getName()) .quantity(orderItem.getQuantity()) .price(orderItem.getMenu().getPrice()) + .status(status) .build(); }🤖 Prompt for AI Agents