From e96cd58239558c1f12024da2443671e4b6f13633 Mon Sep 17 00:00:00 2001 From: hyunn522 Date: Wed, 30 Oct 2024 21:12:09 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20TimeUtil=EC=9D=98=20getEncodedTime=20?= =?UTF-8?q?=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/space/space_spring/service/ChatRoomService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/space/space_spring/service/ChatRoomService.java b/src/main/java/space/space_spring/service/ChatRoomService.java index b94e12e1..ea728aae 100644 --- a/src/main/java/space/space_spring/service/ChatRoomService.java +++ b/src/main/java/space/space_spring/service/ChatRoomService.java @@ -18,6 +18,7 @@ import space.space_spring.entity.enumStatus.BaseStatusType; import space.space_spring.exception.CustomException; +import space.space_spring.global.util.TimeUtils; import space.space_spring.util.space.SpaceUtils; import space.space_spring.util.user.UserUtils; @@ -33,6 +34,7 @@ public class ChatRoomService { private final UserUtils userUtils; private final SpaceUtils spaceUtils; + private final TimeUtils timeUtils; private final UserSpaceDao userSpaceDao; private final ChattingDao chattingDao; private final ChatRoomDao chatRoomDao; @@ -190,7 +192,7 @@ private boolean isUserInChatRoom(User userByUserId, ChatRoom chatRoomByChatRoomI private LastMessageInfoDto getLastMsgInfo(ChatRoom chatRoom) { ChatMessage lastMsg = chattingDao.findTopByChatRoomIdOrderByCreatedAtDesc(chatRoom.getId()); - LocalDateTime lastUpdateTime = lastMsg != null ? lastMsg.getCreatedAt() :chatRoom.getEncodedTime(); + LocalDateTime lastUpdateTime = lastMsg != null ? lastMsg.getCreatedAt() :timeUtils.getEncodedTime(chatRoom.getCreatedAt()); HashMap lastContent = lastMsg != null ? lastMsg.getContent() : new HashMap<>(Map.of("text", "메시지를 전송해보세요")); log.info("마지막으로 업데이트된 시간: " + lastUpdateTime + " 마지막으로 읽은 내용 : " + lastContent); @@ -200,7 +202,7 @@ private LastMessageInfoDto getLastMsgInfo(ChatRoom chatRoom) { private int calculateUnreadMsgCount(User userByUserId, ChatRoom chatRoom, LocalDateTime lastUpdateTime) { UserChatRoom userChatRoom = userChatRoomDao.findByUserAndChatRoomAndStatus(userByUserId, chatRoom, BaseStatusType.ACTIVE); - LocalDateTime lastReadTime = userChatRoom.getEncodedTime(); // LocalDateTime으로 변환 + LocalDateTime lastReadTime = timeUtils.getEncodedTime(userChatRoom.getLastReadTime()); // LocalDateTime으로 변환 log.info("마지막으로 읽은 시간: " + lastReadTime); int unreadMsgCount = chattingDao.countByChatRoomIdAndCreatedAtBetween(