File tree Expand file tree Collapse file tree 11 files changed +99
-99
lines changed
test/kotlin/nexters/tuk/application Expand file tree Collapse file tree 11 files changed +99
-99
lines changed Original file line number Diff line number Diff line change 1+ package nexters.tuk.application.gathering
2+
3+ import nexters.tuk.application.gathering.dto.request.GatheringCommand
4+ import nexters.tuk.application.notification.GatheringNotifier
5+ import nexters.tuk.application.scheduler.GatheringNotificationScheduler
6+ import org.springframework.stereotype.Service
7+
8+ @Service
9+ class GatheringNotificationService (
10+ private val gatheringNotifier : GatheringNotifier ,
11+ private val gatheringNotificationScheduler : GatheringNotificationScheduler
12+ ) {
13+ fun handleGatheringNotification (command : GatheringCommand .Notification ) {
14+ when (command) {
15+ is GatheringCommand .Notification .Tuk -> {
16+ gatheringNotificationScheduler.scheduleTukNotification(command)
17+ }
18+
19+ is GatheringCommand .Notification .Invitation -> {
20+ gatheringNotifier.sendInvitationNotification(command)
21+ }
22+ }
23+ }
24+ }
Original file line number Diff line number Diff line change 1+ package nexters.tuk.application.gathering.dto.request
2+
3+ class GatheringCommand {
4+ sealed class Notification {
5+ data class Tuk (val gatheringId : Long , val intervalDays : Long ) : Notification()
6+ data class Invitation (val gatheringId : Long , val purpose : String ) : Notification()
7+ }
8+ }
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import org.springframework.stereotype.Service
44
55@Service
66class MemberService {
7- fun findTokensByMeetingId ( meetingId : Long ): List <String > {
7+ fun findTokensByGatheringId ( gatheringId : Long ): List <String > {
88 TODO (" Not yet implemented" )
99 }
1010}
Original file line number Diff line number Diff line change 1+ package nexters.tuk.application.notification
2+
3+ import nexters.tuk.application.gathering.dto.request.GatheringCommand
4+ import nexters.tuk.application.member.MemberService
5+ import org.springframework.stereotype.Service
6+
7+
8+ @Service
9+ class GatheringNotifier (
10+ private val memberService : MemberService ,
11+ private val notificationSender : NotificationSender
12+ ) {
13+ fun sendTukNotification (command : GatheringCommand .Notification .Tuk ) {
14+ val tokens = memberService.findTokensByGatheringId(command.gatheringId)
15+ val tukMessage = TukNotificationMessage (command.gatheringId, command.intervalDays)
16+
17+ notificationSender.notifyMembers(tokens, tukMessage)
18+ }
19+
20+ fun sendInvitationNotification (command : GatheringCommand .Notification .Invitation ) {
21+ val tokens = memberService.findTokensByGatheringId(command.gatheringId)
22+ val invitationMessage = InvitationNotificationMessage (command.gatheringId, command.purpose)
23+
24+ notificationSender.notifyMembers(tokens, invitationMessage)
25+ }
26+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ interface NotificationMessage {
66}
77
88class TukNotificationMessage (
9- private val meetingId : Long ,
9+ private val gatheringId : Long ,
1010 private val days : Long ,
1111) : NotificationMessage {
1212
@@ -20,7 +20,7 @@ class TukNotificationMessage(
2020}
2121
2222class InvitationNotificationMessage (
23- private val meetingId : Long ,
23+ private val gatheringId : Long ,
2424 private val purpose : String ,
2525) : NotificationMessage {
2626
Original file line number Diff line number Diff line change 11package nexters.tuk.application.scheduler
22
3- import nexters.tuk.application.meeting .dto.request.MeetingCommand
3+ import nexters.tuk.application.gathering .dto.request.GatheringCommand
44import nexters.tuk.job.TukNotificationJob
55import org.quartz.*
66import org.springframework.stereotype.Component
@@ -9,17 +9,17 @@ import java.time.ZoneId
99import java.util.*
1010
1111@Component
12- class MeetingNotificationScheduler (
12+ class GatheringNotificationScheduler (
1313 private val scheduler : Scheduler ,
1414) {
15- fun scheduleTukNotification (command : MeetingCommand .Notification .Tuk ) {
16- val jobKey = JobKey (command.meetingId .toString(), " notification-job-group" )
17- val triggerKey = TriggerKey (command.meetingId .toString(), " notification-trigger-group" )
15+ fun scheduleTukNotification (command : GatheringCommand .Notification .Tuk ) {
16+ val jobKey = JobKey (command.gatheringId .toString(), " notification-job-group" )
17+ val triggerKey = TriggerKey (command.gatheringId .toString(), " notification-trigger-group" )
1818
1919
2020 val jobDataMap = JobDataMap (
2121 mapOf (
22- " meetingId " to command.meetingId ,
22+ " gatheringId " to command.gatheringId ,
2323 " intervalDays" to command.intervalDays
2424 )
2525 )
Original file line number Diff line number Diff line change 11package nexters.tuk.job
22
3- import nexters.tuk.application.meeting .dto.request.MeetingCommand
4- import nexters.tuk.application.notification.MeetingNotifier
3+ import nexters.tuk.application.gathering .dto.request.GatheringCommand
4+ import nexters.tuk.application.notification.GatheringNotifier
55import org.quartz.Job
66import org.quartz.JobExecutionContext
77import org.springframework.stereotype.Component
88
99@Component
1010class TukNotificationJob (
11- private val meetingNotifier : MeetingNotifier
11+ private val gatheringNotifier : GatheringNotifier
1212) : Job {
1313 override fun execute (context : JobExecutionContext ) {
1414 val jobDataMap = context.mergedJobDataMap
15- val meetingId = jobDataMap[" meetingId " ] as Long
15+ val gatheringId = jobDataMap[" gatheringId " ] as Long
1616 val intervalDays = jobDataMap[" intervalDays" ] as Long
1717
18- val command = MeetingCommand .Notification .Tuk (meetingId , intervalDays)
19- meetingNotifier .sendTukNotification(command)
18+ val command = GatheringCommand .Notification .Tuk (gatheringId , intervalDays)
19+ gatheringNotifier .sendTukNotification(command)
2020 }
2121}
You can’t perform that action at this time.
0 commit comments