Skip to content

Commit 86e983f

Browse files
committed
♻️ :: 리스트 날짜 내림차순으로 정렬
1 parent 33c4095 commit 86e983f

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/service/NotificationDetailApiImpl.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class NotificationDetailApiImpl(
9191
override fun queryNotificationDetail(userId: UUID): DetailResponse {
9292
postDetailRepositorySpi.updateAllDetailByUserIdAndIsReadFalse(userId)
9393
return DetailResponse(
94-
queryDetailRepositorySpi.findAllByUserId(userId)
94+
queryDetailRepositorySpi.findAllByUserIdOrderBySentAtDesc(userId)
9595
.map {
9696
DetailElement(
9797
id = it.id,

notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/spi/QueryDetailRepositorySpi.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ import java.util.UUID
66

77
@Spi
88
interface QueryDetailRepositorySpi {
9-
fun findAllByUserId(userId: UUID): List<TopicDetailModel>
9+
fun findAllByUserIdOrderBySentAtDesc(userId: UUID): List<TopicDetailModel>
1010
fun findAllByUseridAndIsReadFalse(userId: UUID): Int
1111
}

notification-domain/src/main/kotlin/io/github/v1servicenotification/stubs/InMemoryDetailRepository.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class InMemoryDetailRepository(
2121
detailMap[detail.id] = detail
2222
}
2323

24-
override fun findAllByUserId(userId: UUID): List<TopicDetailModel> {
24+
override fun findAllByUserIdOrderBySentAtDesc(userId: UUID): List<TopicDetailModel> {
2525
return detailMap.filter { it.value.userId == userId }
2626
.map {
2727
val category = categoryMap[it.value.categoryId]
@@ -35,7 +35,7 @@ class InMemoryDetailRepository(
3535
it.value.userId,
3636
category.topic,
3737
)
38-
}
38+
}.sortedByDescending { it.sentAt }
3939
}
4040

4141
override fun findAllByUseridAndIsReadFalse(userId: UUID): Int {

notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/detail/domain/repository/CustomDetailRepositoryImpl.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class CustomDetailRepositoryImpl(
1919
private val detailMapper: DetailMapper,
2020
private val query: JPAQueryFactory,
2121
) : QueryDetailRepositorySpi, PostDetailRepositorySpi {
22-
override fun findAllByUserId(userId: UUID): List<TopicDetailModel> {
22+
override fun findAllByUserIdOrderBySentAtDesc(userId: UUID): List<TopicDetailModel> {
2323
return query
2424
.select(
2525
QDetailVO(
@@ -49,7 +49,7 @@ class CustomDetailRepositoryImpl(
4949
topic = it.topic,
5050
)
5151
}
52-
.toList()
52+
.toList().sortedByDescending { it.sentAt }
5353
}
5454

5555
override fun findAllByUseridAndIsReadFalse(userId: UUID): Int {

0 commit comments

Comments
 (0)