캐릭터 챗봇 #338
| @@ -42,19 +42,20 @@ interface ChatRoomRepository : JpaRepository<ChatRoom, Long> { | |||||||
|                 r.title, |                 r.title, | ||||||
|                 pc.character.imagePath, |                 pc.character.imagePath, | ||||||
|                 pc.character.characterType, |                 pc.character.characterType, | ||||||
|                 COALESCE(MAX(m.createdAt), r.createdAt) |                 MAX(m.createdAt) | ||||||
|             ) |             ) | ||||||
|             FROM ChatRoom r |             FROM ChatRoom r | ||||||
|             JOIN r.participants p |             JOIN r.participants p | ||||||
|             JOIN r.participants pc |             JOIN r.participants pc | ||||||
|             LEFT JOIN r.messages m |             JOIN r.messages m | ||||||
|             WHERE p.member = :member |             WHERE p.member = :member | ||||||
|               AND p.isActive = true |               AND p.isActive = true | ||||||
|               AND pc.participantType = kr.co.vividnext.sodalive.chat.room.ParticipantType.CHARACTER |               AND pc.participantType = kr.co.vividnext.sodalive.chat.room.ParticipantType.CHARACTER | ||||||
|               AND pc.isActive = true |               AND pc.isActive = true | ||||||
|               AND r.isActive = true |               AND r.isActive = true | ||||||
|  |               AND m.isActive = true | ||||||
|             GROUP BY r.id, r.title, r.createdAt, pc.character.imagePath, pc.character.characterType |             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( |     fun findMemberRoomsOrderByLastMessageDesc( | ||||||
|   | |||||||
| @@ -30,6 +30,8 @@ import org.springframework.http.client.SimpleClientHttpRequestFactory | |||||||
| import org.springframework.stereotype.Service | import org.springframework.stereotype.Service | ||||||
| import org.springframework.transaction.annotation.Transactional | import org.springframework.transaction.annotation.Transactional | ||||||
| import org.springframework.web.client.RestTemplate | import org.springframework.web.client.RestTemplate | ||||||
|  | import java.time.Duration | ||||||
|  | import java.time.LocalDateTime | ||||||
| import java.util.UUID | import java.util.UUID | ||||||
|  |  | ||||||
| @Service | @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 "" |         if (time == null) return "" | ||||||
|         val now = java.time.LocalDateTime.now() |         val now = LocalDateTime.now() | ||||||
|         val duration = java.time.Duration.between(time, now) |         val duration = Duration.between(time, now) | ||||||
|         val seconds = duration.seconds |         val seconds = duration.seconds | ||||||
|         if (seconds <= 60) return "방금" |         if (seconds <= 60) return "방금" | ||||||
|         val minutes = duration.toMinutes() |         val minutes = duration.toMinutes() | ||||||
|         if (minutes < 60) return "${'$'}minutes분 전" |         if (minutes < 60) return "${minutes}분 전" | ||||||
|         val hours = duration.toHours() |         val hours = duration.toHours() | ||||||
|         if (hours < 24) return "${'$'}hours시간 전" |         if (hours < 24) return "${hours}시간 전" | ||||||
|         // 그 외: 날짜 (yyyy-MM-dd) |         // 그 외: 날짜 (yyyy-MM-dd) | ||||||
|         return time.toLocalDate().toString() |         return time.toLocalDate().toString() | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user