-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from TeamMiso/feat/notification-alarm
๐ :: ํธ์ ์๋ฆผ ๋ก์ง ์ถ๊ฐ
- Loading branch information
Showing
13 changed files
with
151 additions
and
12 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
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
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
5 changes: 5 additions & 0 deletions
5
...311/miso/domain/notification/application/port/input/EnvironmentNotificationSendUseCase.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,5 @@ | ||
package andreas311.miso.domain.notification.application.port.input | ||
|
||
interface EnvironmentNotificationSendUseCase { | ||
fun execute() | ||
} |
7 changes: 7 additions & 0 deletions
7
...reas311/miso/domain/notification/application/port/input/InquiryNotificationSendUseCase.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,7 @@ | ||
package andreas311.miso.domain.notification.application.port.input | ||
|
||
import andreas311.miso.domain.inquiry.domain.Inquiry | ||
|
||
interface InquiryNotificationSendUseCase { | ||
fun execute(inquiry: Inquiry, token: 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
15 changes: 15 additions & 0 deletions
15
...eas311/miso/domain/notification/application/scheduler/EnvironmentNotificationScheduler.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,15 @@ | ||
package andreas311.miso.domain.notification.application.scheduler | ||
|
||
import andreas311.miso.domain.notification.application.port.input.EnvironmentNotificationSendUseCase | ||
import org.springframework.scheduling.annotation.Scheduled | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class EnvironmentNotificationScheduler( | ||
private val environmentNotificationSendUseCase: EnvironmentNotificationSendUseCase | ||
) { | ||
@Scheduled(cron = "0 0 13 * * ?") | ||
fun sendEnvironmentNotification() { | ||
environmentNotificationSendUseCase.execute() | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...eas311/miso/domain/notification/application/service/EnvironmentNotificationSendService.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,31 @@ | ||
package andreas311.miso.domain.notification.application.service | ||
|
||
import andreas311.miso.domain.notification.application.port.input.EnvironmentNotificationSendUseCase | ||
import andreas311.miso.domain.notification.application.port.output.FcmNotificationPort | ||
import andreas311.miso.domain.notification.application.port.output.QueryDeviceTokenPort | ||
import andreas311.miso.domain.notification.domain.NotificationAlarm | ||
import andreas311.miso.domain.notification.domain.NotificationType | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class EnvironmentNotificationSendService( | ||
private val fcmNotificationPort: FcmNotificationPort, | ||
private val queryDeviceTokenPort: QueryDeviceTokenPort | ||
) : EnvironmentNotificationSendUseCase { | ||
override fun execute() { | ||
|
||
runCatching { | ||
fcmNotificationPort.sendEnvironmentNotification( | ||
deviceTokens = queryDeviceTokenPort.findAll().map { it.deviceToken }, | ||
notificationAlarm = NotificationAlarm( | ||
title = NotificationType.ENVIRONMENT.title, | ||
content = NotificationType.ENVIRONMENT.content, | ||
writer = "๋ฏธ์" | ||
) | ||
) | ||
|
||
}.onFailure { | ||
it.printStackTrace() | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...andreas311/miso/domain/notification/application/service/InquiryNotificationSendService.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 andreas311.miso.domain.notification.application.service | ||
|
||
import andreas311.miso.common.annotation.RollbackService | ||
import andreas311.miso.domain.inquiry.domain.Inquiry | ||
import andreas311.miso.domain.inquiry.domain.InquiryStatus | ||
import andreas311.miso.domain.notification.application.port.input.InquiryNotificationSendUseCase | ||
import andreas311.miso.domain.notification.application.port.output.FcmNotificationPort | ||
import andreas311.miso.domain.notification.domain.NotificationAlarm | ||
import andreas311.miso.domain.notification.domain.NotificationType | ||
|
||
@RollbackService | ||
class InquiryNotificationSendService( | ||
private val fcmNotificationPort: FcmNotificationPort | ||
) : InquiryNotificationSendUseCase { | ||
override fun execute(inquiry: Inquiry, token: String) { | ||
val notificationType = when (inquiry.inquiryStatus) { | ||
InquiryStatus.WAIT -> NotificationType.INQUIRY_WAIT | ||
InquiryStatus.COMPLETE -> NotificationType.INQUIRY_COMPLETE | ||
} | ||
|
||
runCatching { | ||
fcmNotificationPort.sendInquiryNotification( | ||
deviceToken = token, | ||
notificationAlarm = NotificationAlarm( | ||
title = notificationType.title, | ||
content = notificationType.content, | ||
writer = "๋ฏธ์" | ||
) | ||
) | ||
|
||
}.onFailure { | ||
it.printStackTrace() | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/andreas311/miso/domain/notification/domain/NotificationType.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,22 @@ | ||
package andreas311.miso.domain.notification.domain | ||
|
||
enum class NotificationType( | ||
val title: String, | ||
val content: String | ||
) { | ||
|
||
INQUIRY_WAIT( | ||
title = "Miso ๋ฌธ์์ฌํญ ๋ฑ๋ก ์๋ฃ!", | ||
content = "์ต๋ํ ๋น ๋ฅด๊ฒ ๋ต๋ณ ๋๋ฆดํ ๋ ๊ธฐ๋ค๋ ค์ฃผ์ธ์ :)" | ||
), | ||
|
||
INQUIRY_COMPLETE( | ||
title = "Miso ๋ฌธ์์ฌํญ ๋ต๋ณ ๋์ฐฉ!", | ||
content = "๋ด ๋ฌธ์ ๋ด์ญ์์ ๋ต๋ณ์ ํ์ธํด์ฃผ์ธ์ :)" | ||
), | ||
|
||
ENVIRONMENT( | ||
title = "์ค๋์ ํ๊ฒฝ ์ง์์ ์๊ณ ์ถ๋ค๋ฉด?", | ||
content = "Miso ์์ ์ค๋์ ํ๊ฒฝ ์ง์์ ํ์ธํด๋ณด์ธ์ :)" | ||
) | ||
} |
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