Skip to content

Commit

Permalink
fix: TimeUtil의 getEncodedTime 메소드 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunn522 committed Oct 30, 2024
1 parent 9268500 commit e96cd58
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/space/space_spring/service/ChatRoomService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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<String, String> lastContent = lastMsg != null ? lastMsg.getContent() : new HashMap<>(Map.of("text", "메시지를 전송해보세요"));

log.info("마지막으로 업데이트된 시간: " + lastUpdateTime + " 마지막으로 읽은 내용 : " + lastContent);
Expand All @@ -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(
Expand Down

0 comments on commit e96cd58

Please sign in to comment.