diff --git a/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java b/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java index 70793a48..828cc9c2 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java @@ -13,6 +13,7 @@ import coffeemeet.server.user.implement.UserQuery; import java.util.List; import lombok.RequiredArgsConstructor; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; @Service @@ -44,11 +45,12 @@ public List searchChattingRoomHistories(Long userId) { .toList(); } - // TODO: 11/20/23 캐쉬 로직 적용 + @Cacheable(value = "chattingMessageHistories", key = "{#roomHistoryId, #firstMessageId, #pageSize}") public ChattingHistoryListDto searchChattingMessageHistories(Long roomHistoryId, Long firstMessageId, int pageSize) { ChattingRoomHistory chattingRoomHistory = chattingRoomHistoryQuery.getChattingRoomHistoryBy( roomHistoryId); + // TODO: 12/22/23 채팅방 3일 지난거면 응답 x List messageHistories = chattingMessageHistoryQuery.getMessageHistories( chattingRoomHistory, firstMessageId, pageSize); diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java index 7157cf6c..03758f51 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java @@ -2,6 +2,10 @@ import coffeemeet.server.user.domain.User; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; import java.time.LocalDateTime; public record ChattingHistory( @@ -11,6 +15,8 @@ public record ChattingHistory( String content, String profileImageUrl, @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + @JsonSerialize(using = LocalDateTimeSerializer.class) + @JsonDeserialize(using = LocalDateTimeDeserializer.class) LocalDateTime createdAt ) {