From 4966aaeda97c6e1de5df91cb8c13855f817a684a Mon Sep 17 00:00:00 2001 From: Klaus Date: Thu, 14 Aug 2025 14:35:07 +0900 Subject: [PATCH] =?UTF-8?q?fix(chat-room):=20=EB=A9=94=EC=8B=9C=EC=A7=80?= =?UTF-8?q?=20=EC=9E=88=EB=8A=94=20=EB=B0=A9=EB=A7=8C=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/room/repository/ChatRoomRepository.kt | 7 ++++--- .../sodalive/chat/room/service/ChatRoomService.kt | 12 +++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/chat/room/repository/ChatRoomRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/chat/room/repository/ChatRoomRepository.kt index 0bdb29b..f161cd8 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/chat/room/repository/ChatRoomRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/chat/room/repository/ChatRoomRepository.kt @@ -42,19 +42,20 @@ interface ChatRoomRepository : JpaRepository { r.title, pc.character.imagePath, pc.character.characterType, - COALESCE(MAX(m.createdAt), r.createdAt) + MAX(m.createdAt) ) FROM ChatRoom r JOIN r.participants p JOIN r.participants pc - LEFT JOIN r.messages m + JOIN r.messages m WHERE p.member = :member AND p.isActive = true AND pc.participantType = kr.co.vividnext.sodalive.chat.room.ParticipantType.CHARACTER AND pc.isActive = true AND r.isActive = true + AND m.isActive = true GROUP BY r.id, r.title, r.createdAt, pc.character.imagePath, pc.character.characterType - ORDER BY COALESCE(MAX(m.createdAt), r.createdAt) DESC + ORDER BY MAX(m.createdAt) DESC """ ) fun findMemberRoomsOrderByLastMessageDesc( diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/chat/room/service/ChatRoomService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/chat/room/service/ChatRoomService.kt index 9ecedeb..aa54e26 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/chat/room/service/ChatRoomService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/chat/room/service/ChatRoomService.kt @@ -30,6 +30,8 @@ import org.springframework.http.client.SimpleClientHttpRequestFactory import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import org.springframework.web.client.RestTemplate +import java.time.Duration +import java.time.LocalDateTime import java.util.UUID @Service @@ -218,16 +220,16 @@ class ChatRoomService( } } - private fun formatRelativeTime(time: java.time.LocalDateTime?): String { + private fun formatRelativeTime(time: LocalDateTime?): String { if (time == null) return "" - val now = java.time.LocalDateTime.now() - val duration = java.time.Duration.between(time, now) + val now = LocalDateTime.now() + val duration = Duration.between(time, now) val seconds = duration.seconds if (seconds <= 60) return "방금" val minutes = duration.toMinutes() - if (minutes < 60) return "${'$'}minutes분 전" + if (minutes < 60) return "${minutes}분 전" val hours = duration.toHours() - if (hours < 24) return "${'$'}hours시간 전" + if (hours < 24) return "${hours}시간 전" // 그 외: 날짜 (yyyy-MM-dd) return time.toLocalDate().toString() }