Skip to content

Commit 8306fd4

Browse files
authored
Merge pull request #242 from prgrms-web-devcourse-final-project/#0
refactor: 경매방 단건 조회 시 현재 가격을 redis에서 읽어오게 변경
2 parents 6aea374 + 5a29e2d commit 8306fd4

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/main/java/devut/buzzerbidder/domain/auctionroom/service/AuctionRoomService.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,23 @@ public AuctionRoomResponse getAuctionRoom(Long auctionRoomId) {
247247
remainingMs = liveBidRedisService.getRemainingToStartMs(nextItem.getId());
248248
}
249249

250-
List<AuctionRoomItemDto> response = items.stream()
251-
.map(item -> new AuctionRoomItemDto(
252-
item.getId(),
253-
item.getName(),
254-
item.getImages().stream()
255-
.map(LiveItemImage::getImageUrl)
256-
.toList(),
257-
item.getInitPrice(),
258-
Long.parseLong((String) redisTemplate.opsForHash().get("liveItem:" + item.getId(), "maxBidPrice")),
259-
item.getAuctionStatus()
260-
))
261-
.toList();
250+
List<AuctionRoomItemDto> response = items.stream()
251+
.map(item -> {
252+
Object v = redisTemplate.opsForHash().get("liveItem:" + item.getId(), "maxBidPrice");
253+
Long maxBidPrice = (v == null) ? null : Long.parseLong(v.toString());
254+
255+
return new AuctionRoomItemDto(
256+
item.getId(),
257+
item.getName(),
258+
item.getImages().stream()
259+
.map(LiveItemImage::getImageUrl)
260+
.toList(),
261+
item.getInitPrice(),
262+
maxBidPrice,
263+
item.getAuctionStatus()
264+
);
265+
})
266+
.toList();
262267

263268
return new AuctionRoomResponse(remainingMs, response);
264269

0 commit comments

Comments
 (0)