Skip to content

Commit 73aad4d

Browse files
authored
🔀 :: (#26) 리스트 날짜 내림차순으로 정렬
🔀 :: (#26) 리스트 날짜 내림차순으로 정렬
2 parents 33c4095 + d3ae1fb commit 73aad4d

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
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-domain/src/test/kotlin/io/github/v1servicenotification/detail/DetailApiImplTest.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ class DetailApiImplTest {
7575

7676
detailApi.postGroupNotification(category.topic, content, threadId)
7777

78-
assertThat(detailSpi.findAllByUserId(userId).size).isEqualTo(1)
78+
assertThat(detailSpi.findAllByUserIdOrderBySentAtDesc(userId).size).isEqualTo(1)
7979

80-
detailSpi.findAllByUserId(userId)
80+
detailSpi.findAllByUserIdOrderBySentAtDesc(userId)
8181
.forEach {
8282
assertThat(it.title).isEqualTo(title)
8383
assertThat(it.content).isEqualTo(content)
@@ -110,7 +110,7 @@ class DetailApiImplTest {
110110

111111
detailApi.postGroupNotification(category.topic, content, threadId)
112112

113-
detailSpi.findAllByUserId(userId)
113+
detailSpi.findAllByUserIdOrderBySentAtDesc(userId)
114114
.forEach {
115115
assertThat(it.title).isEqualTo(title)
116116
assertThat(it.content).isEqualTo(content)
@@ -143,7 +143,7 @@ class DetailApiImplTest {
143143

144144
detailApi.postGroupNotification(category.topic, content, threadId)
145145

146-
detailSpi.findAllByUserId(userId)
146+
detailSpi.findAllByUserIdOrderBySentAtDesc(userId)
147147
.forEach {
148148
assertThat(it.title).isEqualTo(title)
149149
assertThat(it.content).isEqualTo(content)
@@ -181,7 +181,7 @@ class DetailApiImplTest {
181181

182182
detailApi.postNotification(userId, category.topic, content, threadId)
183183

184-
detailSpi.findAllByUserId(userId)
184+
detailSpi.findAllByUserIdOrderBySentAtDesc(userId)
185185
.forEach {
186186
assertThat(it.title).isEqualTo(title)
187187
assertThat(it.content).isEqualTo(content)

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)