refactor(home): UTC 시간 포맷 변환을 재사용한다
This commit is contained in:
@@ -1,15 +1,10 @@
|
||||
package kr.co.vividnext.sodalive.v2.api.home.dto
|
||||
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import java.time.ZoneOffset
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
private val KST_ZONE: ZoneId = ZoneId.of("Asia/Seoul")
|
||||
|
||||
internal fun LocalDateTime.toUtcIso(): String {
|
||||
val instant = this.atZone(KST_ZONE).withZoneSameInstant(ZoneOffset.UTC).toInstant()
|
||||
return DateTimeFormatter.ISO_INSTANT.format(instant)
|
||||
return this.atOffset(ZoneOffset.UTC).toInstant().toString()
|
||||
}
|
||||
|
||||
internal fun imageUrl(cloudFrontHost: String, path: String?): String? {
|
||||
|
||||
@@ -4,6 +4,7 @@ import kr.co.vividnext.sodalive.chat.room.ChatMessageType
|
||||
import kr.co.vividnext.sodalive.chat.room.repository.ChatRoomRepository
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.v2.api.home.dto.toUtcIso
|
||||
import kr.co.vividnext.sodalive.v2.chat.dto.ChatRoomListItemResponse
|
||||
import kr.co.vividnext.sodalive.v2.chat.dto.ChatRoomListPageResponse
|
||||
import kr.co.vividnext.sodalive.v2.chat.dto.ChatRoomListQueryDto
|
||||
@@ -14,7 +15,6 @@ import org.springframework.data.domain.PageRequest
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneOffset
|
||||
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
@@ -90,7 +90,7 @@ class ChatRoomListService(
|
||||
targetName = targetName,
|
||||
targetImageUrl = imageUrl(targetImagePath),
|
||||
lastMessage = previewMessage(),
|
||||
lastMessageAt = lastMessageAt.toUtcIsoString()
|
||||
lastMessageAt = lastMessageAt.toUtcIso()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -118,10 +118,6 @@ class ChatRoomListService(
|
||||
return ChatRoomListCursor(lastMessageAt, chatType, roomId)
|
||||
}
|
||||
|
||||
private fun LocalDateTime.toUtcIsoString(): String {
|
||||
return atOffset(ZoneOffset.UTC).toInstant().toString()
|
||||
}
|
||||
|
||||
private fun ChatRoomListQueryDto.isAfter(cursor: ChatRoomListCursor): Boolean {
|
||||
if (lastMessageAt.isBefore(cursor.lastMessageAt)) return true
|
||||
if (lastMessageAt.isAfter(cursor.lastMessageAt)) return false
|
||||
|
||||
Reference in New Issue
Block a user