From 16d60c38d43e4af57c23cf7696717502740d2789 Mon Sep 17 00:00:00 2001 From: jihwan2da Date: Thu, 23 Nov 2023 21:47:03 +0900 Subject: [PATCH] =?UTF-8?q?refactor(application):=20notification=20event?= =?UTF-8?q?=20=EC=B6=94=EC=83=81=ED=99=94=20=EC=9E=91=EC=97=85=20=EB=B0=8F?= =?UTF-8?q?=20event=20publisher=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=EB=B0=8D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/NotificationCreateEvent.kt | 23 +++++++++++-------- .../notification/event/NotificationEvent.kt | 4 ++++ .../event/NotificationEventPublisher.kt | 2 +- .../service/ApplyNotificationCreateService.kt | 4 ++-- .../service/GroupNotificationCreateService.kt | 10 ++++---- 5 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 notification-application/src/main/kotlin/gloddy/notification/event/NotificationEvent.kt diff --git a/notification-application/src/main/kotlin/gloddy/notification/event/NotificationCreateEvent.kt b/notification-application/src/main/kotlin/gloddy/notification/event/NotificationCreateEvent.kt index c8a3028..834714d 100644 --- a/notification-application/src/main/kotlin/gloddy/notification/event/NotificationCreateEvent.kt +++ b/notification-application/src/main/kotlin/gloddy/notification/event/NotificationCreateEvent.kt @@ -1,15 +1,18 @@ package gloddy.notification.event import gloddy.notification.Notification +import gloddy.notification.NotificationType +import gloddy.notification.UserId -class NotificationCreateNotificationEvent( - val notification: Notification -) : NotificationEvent +fun Notification.toNotificationCreateEvent(): NotificationCreateEvent = + NotificationCreateEvent( + userId = this.userId, + redirectId = this.redirectId, + type = this.type + ) -//fun Notification.toEntity(): NotificationPushEvent = -// NotificationPushEvent( -// userId = this.userId, -// content = this.content, -// type = this.type, -// redirectId = this.redirectId -// ) \ No newline at end of file +class NotificationCreateEvent( + val userId: UserId, + val redirectId: Long, + val type: NotificationType +) : NotificationEvent \ No newline at end of file diff --git a/notification-application/src/main/kotlin/gloddy/notification/event/NotificationEvent.kt b/notification-application/src/main/kotlin/gloddy/notification/event/NotificationEvent.kt new file mode 100644 index 0000000..78fafd5 --- /dev/null +++ b/notification-application/src/main/kotlin/gloddy/notification/event/NotificationEvent.kt @@ -0,0 +1,4 @@ +package gloddy.notification.event + +interface NotificationEvent { +} \ No newline at end of file diff --git a/notification-application/src/main/kotlin/gloddy/notification/event/NotificationEventPublisher.kt b/notification-application/src/main/kotlin/gloddy/notification/event/NotificationEventPublisher.kt index 1272159..7ecc507 100644 --- a/notification-application/src/main/kotlin/gloddy/notification/event/NotificationEventPublisher.kt +++ b/notification-application/src/main/kotlin/gloddy/notification/event/NotificationEventPublisher.kt @@ -8,7 +8,7 @@ class NotificationEventPublisher( private val applicationEventPublisher: ApplicationEventPublisher ) { - fun publishPushEvent(event: NotificationPushEvent) { + fun publishEvent(event: NotificationEvent) { applicationEventPublisher.publishEvent(event) } } \ No newline at end of file diff --git a/notification-application/src/main/kotlin/gloddy/notification/service/ApplyNotificationCreateService.kt b/notification-application/src/main/kotlin/gloddy/notification/service/ApplyNotificationCreateService.kt index 97687e1..ff4688c 100644 --- a/notification-application/src/main/kotlin/gloddy/notification/service/ApplyNotificationCreateService.kt +++ b/notification-application/src/main/kotlin/gloddy/notification/service/ApplyNotificationCreateService.kt @@ -3,8 +3,8 @@ package gloddy.notification.service import gloddy.notification.* import gloddy.notification.NotificationType.APPLY_CREATE import gloddy.notification.dto.ApplyEvent -import gloddy.notification.event.NotificationPushEvent import gloddy.notification.event.NotificationEventPublisher +import gloddy.notification.event.toNotificationCreateEvent import gloddy.notification.port.`in`.ApplyNotificationCreateUseCase import gloddy.notification.port.out.NotificationCreatePort import org.springframework.stereotype.Service @@ -25,7 +25,7 @@ class ApplyNotificationCreateService( type = type ).run { notificationCreatePort.save(this) - notificationEventPublisher.publishPushEvent(NotificationPushEvent(this)) + notificationEventPublisher.publishEvent(this.toNotificationCreateEvent()) } } diff --git a/notification-application/src/main/kotlin/gloddy/notification/service/GroupNotificationCreateService.kt b/notification-application/src/main/kotlin/gloddy/notification/service/GroupNotificationCreateService.kt index 9b7d4a4..3da7e95 100644 --- a/notification-application/src/main/kotlin/gloddy/notification/service/GroupNotificationCreateService.kt +++ b/notification-application/src/main/kotlin/gloddy/notification/service/GroupNotificationCreateService.kt @@ -4,8 +4,8 @@ import gloddy.notification.* import gloddy.notification.dto.GroupArticleEvent import gloddy.notification.dto.GroupEvent import gloddy.notification.dto.GroupStatusEvent -import gloddy.notification.event.NotificationPushEvent import gloddy.notification.event.NotificationEventPublisher +import gloddy.notification.event.toNotificationCreateEvent import gloddy.notification.port.`in`.GroupNotificationCreateUseCase import gloddy.notification.port.out.NotificationCreatePort import org.springframework.stereotype.Service @@ -29,7 +29,7 @@ class GroupNotificationCreateService( type = notificationType ).run { notificationCreatePort.save(this) - notificationEventPublisher.publishPushEvent(NotificationPushEvent(this)) + notificationEventPublisher.publishEvent(this.toNotificationCreateEvent()) } } @@ -44,7 +44,7 @@ class GroupNotificationCreateService( type = notificationType ).run { notificationCreatePort.save(this) - notificationEventPublisher.publishPushEvent(NotificationPushEvent(this)) + notificationEventPublisher.publishEvent(this.toNotificationCreateEvent()) } } } @@ -55,12 +55,12 @@ class GroupNotificationCreateService( event.groupMemberUserIds.forEach { Notification( userId = it, - redirectId = event.articleId, + redirectId = event.groupId, content = notificationType.content, type = notificationType ).run { notificationCreatePort.save(this) - notificationEventPublisher.publishPushEvent(NotificationPushEvent(this)) + notificationEventPublisher.publishEvent(this.toNotificationCreateEvent()) } } }