Skip to content

Commit 677d3a6

Browse files
committed
refactor: meeting 도메인 명을 gathering으로 변경
1 parent a4fa4d7 commit 677d3a6

File tree

11 files changed

+99
-99
lines changed

11 files changed

+99
-99
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
}

tuk-batch/src/main/kotlin/nexters/tuk/application/meeting/MeetingNotificationService.kt

Lines changed: 0 additions & 24 deletions
This file was deleted.

tuk-batch/src/main/kotlin/nexters/tuk/application/meeting/dto/request/MeetingCommand.kt

Lines changed: 0 additions & 8 deletions
This file was deleted.

tuk-batch/src/main/kotlin/nexters/tuk/application/member/MemberService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.springframework.stereotype.Service
44

55
@Service
66
class MemberService {
7-
fun findTokensByMeetingId(meetingId: Long): List<String> {
7+
fun findTokensByGatheringId(gatheringId: Long): List<String> {
88
TODO("Not yet implemented")
99
}
1010
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
}

tuk-batch/src/main/kotlin/nexters/tuk/application/notification/MeetingNotifier.kt

Lines changed: 0 additions & 26 deletions
This file was deleted.

tuk-batch/src/main/kotlin/nexters/tuk/application/notification/NotificationMessage.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface NotificationMessage {
66
}
77

88
class 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

2222
class InvitationNotificationMessage(
23-
private val meetingId: Long,
23+
private val gatheringId: Long,
2424
private val purpose: String,
2525
) : NotificationMessage {
2626

tuk-batch/src/main/kotlin/nexters/tuk/application/scheduler/MeetingNotificationScheduler.kt renamed to tuk-batch/src/main/kotlin/nexters/tuk/application/scheduler/GatheringNotificationScheduler.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package nexters.tuk.application.scheduler
22

3-
import nexters.tuk.application.meeting.dto.request.MeetingCommand
3+
import nexters.tuk.application.gathering.dto.request.GatheringCommand
44
import nexters.tuk.job.TukNotificationJob
55
import org.quartz.*
66
import org.springframework.stereotype.Component
@@ -9,17 +9,17 @@ import java.time.ZoneId
99
import 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
)
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
package 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
55
import org.quartz.Job
66
import org.quartz.JobExecutionContext
77
import org.springframework.stereotype.Component
88

99
@Component
1010
class 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
}

0 commit comments

Comments
 (0)