From 86e983ff8cc0f22539260923a2baed34ddcddeab Mon Sep 17 00:00:00 2001 From: seongwon Date: Tue, 9 May 2023 20:23:31 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EB=82=A0=EC=A7=9C=20=EB=82=B4=EB=A6=BC?= =?UTF-8?q?=EC=B0=A8=EC=88=9C=EC=9C=BC=EB=A1=9C=20=EC=A0=95=EB=A0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detail/service/NotificationDetailApiImpl.kt | 2 +- .../detail/spi/QueryDetailRepositorySpi.kt | 2 +- .../v1servicenotification/stubs/InMemoryDetailRepository.kt | 4 ++-- .../detail/domain/repository/CustomDetailRepositoryImpl.kt | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/service/NotificationDetailApiImpl.kt b/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/service/NotificationDetailApiImpl.kt index ac10d54c..87573bdd 100644 --- a/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/service/NotificationDetailApiImpl.kt +++ b/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/service/NotificationDetailApiImpl.kt @@ -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, diff --git a/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/spi/QueryDetailRepositorySpi.kt b/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/spi/QueryDetailRepositorySpi.kt index fdb1cdba..f6c849f4 100644 --- a/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/spi/QueryDetailRepositorySpi.kt +++ b/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/spi/QueryDetailRepositorySpi.kt @@ -6,6 +6,6 @@ import java.util.UUID @Spi interface QueryDetailRepositorySpi { - fun findAllByUserId(userId: UUID): List + fun findAllByUserIdOrderBySentAtDesc(userId: UUID): List fun findAllByUseridAndIsReadFalse(userId: UUID): Int } diff --git a/notification-domain/src/main/kotlin/io/github/v1servicenotification/stubs/InMemoryDetailRepository.kt b/notification-domain/src/main/kotlin/io/github/v1servicenotification/stubs/InMemoryDetailRepository.kt index 6236274d..0d1617bc 100644 --- a/notification-domain/src/main/kotlin/io/github/v1servicenotification/stubs/InMemoryDetailRepository.kt +++ b/notification-domain/src/main/kotlin/io/github/v1servicenotification/stubs/InMemoryDetailRepository.kt @@ -21,7 +21,7 @@ class InMemoryDetailRepository( detailMap[detail.id] = detail } - override fun findAllByUserId(userId: UUID): List { + override fun findAllByUserIdOrderBySentAtDesc(userId: UUID): List { return detailMap.filter { it.value.userId == userId } .map { val category = categoryMap[it.value.categoryId] @@ -35,7 +35,7 @@ class InMemoryDetailRepository( it.value.userId, category.topic, ) - } + }.sortedByDescending { it.sentAt } } override fun findAllByUseridAndIsReadFalse(userId: UUID): Int { diff --git a/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/detail/domain/repository/CustomDetailRepositoryImpl.kt b/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/detail/domain/repository/CustomDetailRepositoryImpl.kt index 31596035..9fb621b4 100644 --- a/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/detail/domain/repository/CustomDetailRepositoryImpl.kt +++ b/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/detail/domain/repository/CustomDetailRepositoryImpl.kt @@ -19,7 +19,7 @@ class CustomDetailRepositoryImpl( private val detailMapper: DetailMapper, private val query: JPAQueryFactory, ) : QueryDetailRepositorySpi, PostDetailRepositorySpi { - override fun findAllByUserId(userId: UUID): List { + override fun findAllByUserIdOrderBySentAtDesc(userId: UUID): List { return query .select( QDetailVO( @@ -49,7 +49,7 @@ class CustomDetailRepositoryImpl( topic = it.topic, ) } - .toList() + .toList().sortedByDescending { it.sentAt } } override fun findAllByUseridAndIsReadFalse(userId: UUID): Int { From d3ae1fb37b8ba9c6e2e7109dab342f6dd50ea0df Mon Sep 17 00:00:00 2001 From: seongwon Date: Tue, 9 May 2023 22:07:13 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20test=EB=AC=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v1servicenotification/detail/DetailApiImplTest.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/notification-domain/src/test/kotlin/io/github/v1servicenotification/detail/DetailApiImplTest.kt b/notification-domain/src/test/kotlin/io/github/v1servicenotification/detail/DetailApiImplTest.kt index d80723d4..2c3c6f41 100644 --- a/notification-domain/src/test/kotlin/io/github/v1servicenotification/detail/DetailApiImplTest.kt +++ b/notification-domain/src/test/kotlin/io/github/v1servicenotification/detail/DetailApiImplTest.kt @@ -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) @@ -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) @@ -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) @@ -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)