Skip to content

Commit

Permalink
refactor(application): notification event 추상화 작업 및 event publisher 메소…
Browse files Browse the repository at this point in the history
…드 네이밍 변경
  • Loading branch information
jihwan2da committed Nov 23, 2023
1 parent b863577 commit 16d60c3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -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
// )
class NotificationCreateEvent(
val userId: UserId,
val redirectId: Long,
val type: NotificationType
) : NotificationEvent
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package gloddy.notification.event

interface NotificationEvent {
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class NotificationEventPublisher(
private val applicationEventPublisher: ApplicationEventPublisher
) {

fun publishPushEvent(event: NotificationPushEvent) {
fun publishEvent(event: NotificationEvent) {
applicationEventPublisher.publishEvent(event)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,7 +25,7 @@ class ApplyNotificationCreateService(
type = type
).run {
notificationCreatePort.save(this)
notificationEventPublisher.publishPushEvent(NotificationPushEvent(this))
notificationEventPublisher.publishEvent(this.toNotificationCreateEvent())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,7 +29,7 @@ class GroupNotificationCreateService(
type = notificationType
).run {
notificationCreatePort.save(this)
notificationEventPublisher.publishPushEvent(NotificationPushEvent(this))
notificationEventPublisher.publishEvent(this.toNotificationCreateEvent())
}
}

Expand All @@ -44,7 +44,7 @@ class GroupNotificationCreateService(
type = notificationType
).run {
notificationCreatePort.save(this)
notificationEventPublisher.publishPushEvent(NotificationPushEvent(this))
notificationEventPublisher.publishEvent(this.toNotificationCreateEvent())
}
}
}
Expand All @@ -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())
}
}
}
Expand Down

0 comments on commit 16d60c3

Please sign in to comment.