-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
372 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...e/application/user/center/service/event/CenterManagerVerificationApproveEventPublisher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.swm.idle.application.user.center.service.event | ||
|
||
import com.swm.idle.domain.user.center.event.CenterManagerVerificationApproveEvent | ||
import org.springframework.context.ApplicationEventPublisher | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class CenterManagerVerificationApproveEventPublisher( | ||
private val eventPublisher: ApplicationEventPublisher, | ||
) { | ||
|
||
fun publish(centerManagerVerificationApproveEvent: CenterManagerVerificationApproveEvent) { | ||
eventPublisher.publishEvent(centerManagerVerificationApproveEvent) | ||
} | ||
|
||
} | ||
|
17 changes: 17 additions & 0 deletions
17
...le/application/user/center/service/event/CenterManagerVerificationRejectEventPublisher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.swm.idle.application.user.center.service.event | ||
|
||
import com.swm.idle.domain.user.center.event.CenterManagerVerificationRejectEvent | ||
import org.springframework.context.ApplicationEventPublisher | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class CenterManagerVerificationRejectEventPublisher( | ||
private val eventPublisher: ApplicationEventPublisher, | ||
) { | ||
|
||
fun publish(centerManagerVerificationRejectEvent: CenterManagerVerificationRejectEvent) { | ||
eventPublisher.publishEvent(centerManagerVerificationRejectEvent) | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...m/swm/idle/application/user/center/vo/CenterManagerVerificationApproveNotificationInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.swm.idle.application.user.center.vo | ||
|
||
import com.swm.idle.domain.notification.enums.NotificationType | ||
import com.swm.idle.domain.notification.event.NotificationInfo | ||
import java.util.* | ||
|
||
data class CenterManagerVerificationApproveNotificationInfo( | ||
override val title: String, | ||
override val body: String, | ||
override val receiverId: UUID, | ||
override val notificationType: NotificationType, | ||
override val imageUrl: String?, | ||
override val notificationDetails: Map<String, Any>?, | ||
) : NotificationInfo { | ||
|
||
companion object { | ||
|
||
fun of( | ||
title: String, | ||
body: String, | ||
receiverId: UUID, | ||
notificationType: NotificationType, | ||
): CenterManagerVerificationApproveNotificationInfo { | ||
return CenterManagerVerificationApproveNotificationInfo( | ||
title, | ||
body, | ||
receiverId, | ||
notificationType, | ||
null, | ||
null | ||
) | ||
} | ||
|
||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...om/swm/idle/application/user/center/vo/CenterManagerVerificationRejectNotificationInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.swm.idle.application.user.center.vo | ||
|
||
import com.swm.idle.domain.notification.enums.NotificationType | ||
import com.swm.idle.domain.notification.event.NotificationInfo | ||
import java.util.* | ||
|
||
data class CenterManagerVerificationRejectNotificationInfo( | ||
override val title: String, | ||
override val body: String, | ||
override val receiverId: UUID, | ||
override val notificationType: NotificationType, | ||
override val imageUrl: String?, | ||
override val notificationDetails: Map<String, Any>?, | ||
) : NotificationInfo { | ||
|
||
companion object { | ||
|
||
fun of( | ||
title: String, | ||
body: String, | ||
receiverId: UUID, | ||
notificationType: NotificationType, | ||
): CenterManagerVerificationApproveNotificationInfo { | ||
return CenterManagerVerificationApproveNotificationInfo( | ||
title, | ||
body, | ||
receiverId, | ||
notificationType, | ||
null, | ||
null | ||
) | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...ain/kotlin/com/swm/idle/domain/user/center/event/CenterManagerVerificationApproveEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.swm.idle.domain.user.center.event | ||
|
||
import com.swm.idle.domain.notification.event.NotificationInfo | ||
import java.util.* | ||
|
||
data class CenterManagerVerificationApproveEvent( | ||
val notificationId: UUID, | ||
val notificationInfo: NotificationInfo, | ||
val deviceToken: String, | ||
) |
10 changes: 10 additions & 0 deletions
10
...main/kotlin/com/swm/idle/domain/user/center/event/CenterManagerVerificationRejectEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.swm.idle.domain.user.center.event | ||
|
||
import com.swm.idle.domain.notification.event.NotificationInfo | ||
import java.util.* | ||
|
||
data class CenterManagerVerificationRejectEvent( | ||
val notificationId: UUID, | ||
val notificationInfo: NotificationInfo, | ||
val deviceToken: String, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...m/idle/infrastructure/fcm/users/listener/CenterManagerVerificationApproveEventListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.swm.idle.infrastructure.fcm.users.listener | ||
|
||
import com.swm.idle.domain.user.center.event.CenterManagerVerificationApproveEvent | ||
import com.swm.idle.infrastructure.fcm.users.service.CenterManagerVerificationApproveEventService | ||
import org.springframework.context.event.EventListener | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class CenterManagerVerificationApproveEventListener( | ||
private val centerManagerVerificationApproveEventService: CenterManagerVerificationApproveEventService, | ||
) { | ||
|
||
@EventListener | ||
fun handleCenterManagerVerifyApproveEvent(centerManagerVerificationApproveEvent: CenterManagerVerificationApproveEvent) { | ||
centerManagerVerificationApproveEventService.send(centerManagerVerificationApproveEvent) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...wm/idle/infrastructure/fcm/users/listener/CenterManagerVerificationRejectEventListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.swm.idle.infrastructure.fcm.users.listener | ||
|
||
import com.swm.idle.domain.user.center.event.CenterManagerVerificationRejectEvent | ||
import com.swm.idle.infrastructure.fcm.users.service.CenterManagerVerificationRejectEventService | ||
import org.springframework.context.event.EventListener | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class CenterManagerVerificationRejectEventListener( | ||
private val centerManagerVerificationRejectEventService: CenterManagerVerificationRejectEventService, | ||
) { | ||
|
||
@EventListener | ||
fun handleCenterManagerVerifyRejectEvent(centerManagerVerificationRejectEvent: CenterManagerVerificationRejectEvent) { | ||
centerManagerVerificationRejectEventService.send(centerManagerVerificationRejectEvent) | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
...swm/idle/infrastructure/fcm/users/service/CenterManagerVerificationApproveEventService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.swm.idle.infrastructure.fcm.users.service | ||
|
||
import com.google.firebase.messaging.Message | ||
import com.google.firebase.messaging.Notification | ||
import com.swm.idle.domain.user.center.event.CenterManagerVerificationApproveEvent | ||
import com.swm.idle.infrastructure.fcm.common.client.FcmClient | ||
import io.github.oshai.kotlinlogging.KotlinLogging | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class CenterManagerVerificationApproveEventService( | ||
private val fcmClient: FcmClient, | ||
) { | ||
|
||
private val logger = KotlinLogging.logger {} | ||
|
||
fun send(centerManagerVerificationApproveEvent: CenterManagerVerificationApproveEvent) { | ||
val message = createMessage(centerManagerVerificationApproveEvent) | ||
|
||
try { | ||
fcmClient.send(message) | ||
} catch (e: Exception) { | ||
logger.warn { "FCM 알림 전송에 실패했습니다 : ${message}, 실패한 Event : CenterManagerVerificationApproveEvent" } | ||
} | ||
} | ||
|
||
|
||
private fun createJobPostingNotification(centerManagerVerificationApproveEvent: CenterManagerVerificationApproveEvent): Notification { | ||
return Notification.builder() | ||
.setTitle(centerManagerVerificationApproveEvent.notificationInfo.title) | ||
.setBody(centerManagerVerificationApproveEvent.notificationInfo.body) | ||
.build() | ||
} | ||
|
||
private fun createMessage(centerManagerVerificationApproveEvent: CenterManagerVerificationApproveEvent): Message { | ||
val createJobPostingNotification = | ||
createJobPostingNotification(centerManagerVerificationApproveEvent) | ||
|
||
return Message.builder() | ||
.setToken(centerManagerVerificationApproveEvent.deviceToken) | ||
.setNotification(createJobPostingNotification) | ||
.putData( | ||
"notificationId", | ||
centerManagerVerificationApproveEvent.notificationId.toString() | ||
) | ||
.putData( | ||
"notificationType", | ||
centerManagerVerificationApproveEvent.notificationInfo.notificationType.toString() | ||
) | ||
.build(); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.