Skip to content

Commit

Permalink
🔀 :: (#26) 리스트 날짜 내림차순으로 정렬
Browse files Browse the repository at this point in the history
🔀 :: (#26) 리스트 날짜 내림차순으로 정렬
  • Loading branch information
lilseongwon authored May 10, 2023
2 parents 33c4095 + d3ae1fb commit 73aad4d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class NotificationDetailApiImpl(
override fun queryNotificationDetail(userId: UUID): DetailResponse {
postDetailRepositorySpi.updateAllDetailByUserIdAndIsReadFalse(userId)
return DetailResponse(
queryDetailRepositorySpi.findAllByUserId(userId)
queryDetailRepositorySpi.findAllByUserIdOrderBySentAtDesc(userId)
.map {
DetailElement(
id = it.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import java.util.UUID

@Spi
interface QueryDetailRepositorySpi {
fun findAllByUserId(userId: UUID): List<TopicDetailModel>
fun findAllByUserIdOrderBySentAtDesc(userId: UUID): List<TopicDetailModel>
fun findAllByUseridAndIsReadFalse(userId: UUID): Int
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class InMemoryDetailRepository(
detailMap[detail.id] = detail
}

override fun findAllByUserId(userId: UUID): List<TopicDetailModel> {
override fun findAllByUserIdOrderBySentAtDesc(userId: UUID): List<TopicDetailModel> {
return detailMap.filter { it.value.userId == userId }
.map {
val category = categoryMap[it.value.categoryId]
Expand All @@ -35,7 +35,7 @@ class InMemoryDetailRepository(
it.value.userId,
category.topic,
)
}
}.sortedByDescending { it.sentAt }
}

override fun findAllByUseridAndIsReadFalse(userId: UUID): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ class DetailApiImplTest {

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

assertThat(detailSpi.findAllByUserId(userId).size).isEqualTo(1)
assertThat(detailSpi.findAllByUserIdOrderBySentAtDesc(userId).size).isEqualTo(1)

detailSpi.findAllByUserId(userId)
detailSpi.findAllByUserIdOrderBySentAtDesc(userId)
.forEach {
assertThat(it.title).isEqualTo(title)
assertThat(it.content).isEqualTo(content)
Expand Down Expand Up @@ -110,7 +110,7 @@ class DetailApiImplTest {

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

detailSpi.findAllByUserId(userId)
detailSpi.findAllByUserIdOrderBySentAtDesc(userId)
.forEach {
assertThat(it.title).isEqualTo(title)
assertThat(it.content).isEqualTo(content)
Expand Down Expand Up @@ -143,7 +143,7 @@ class DetailApiImplTest {

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

detailSpi.findAllByUserId(userId)
detailSpi.findAllByUserIdOrderBySentAtDesc(userId)
.forEach {
assertThat(it.title).isEqualTo(title)
assertThat(it.content).isEqualTo(content)
Expand Down Expand Up @@ -181,7 +181,7 @@ class DetailApiImplTest {

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

detailSpi.findAllByUserId(userId)
detailSpi.findAllByUserIdOrderBySentAtDesc(userId)
.forEach {
assertThat(it.title).isEqualTo(title)
assertThat(it.content).isEqualTo(content)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CustomDetailRepositoryImpl(
private val detailMapper: DetailMapper,
private val query: JPAQueryFactory,
) : QueryDetailRepositorySpi, PostDetailRepositorySpi {
override fun findAllByUserId(userId: UUID): List<TopicDetailModel> {
override fun findAllByUserIdOrderBySentAtDesc(userId: UUID): List<TopicDetailModel> {
return query
.select(
QDetailVO(
Expand Down Expand Up @@ -49,7 +49,7 @@ class CustomDetailRepositoryImpl(
topic = it.topic,
)
}
.toList()
.toList().sortedByDescending { it.sentAt }
}

override fun findAllByUseridAndIsReadFalse(userId: UUID): Int {
Expand Down

0 comments on commit 73aad4d

Please sign in to comment.