Skip to content

Commit a4fa4d7

Browse files
authored
Merge pull request #7 from Nexters/feat/init-tuk-batch
배치모듈 환경세팅
2 parents bae0515 + 2be71ad commit a4fa4d7

File tree

20 files changed

+553
-3
lines changed

20 files changed

+553
-3
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ jobs:
3535
restore-keys: |
3636
${{ runner.os }}-gradle-
3737
38+
- name: Copy config file
39+
run: echo "${{ secrets.FIREBASE_ADMINSDK }}" | base64 --decode > ./tuk-batch/src/main/resources/firebase-adminsdk.json
40+
41+
3842
- name: Build with Gradle
3943
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
4044
with:

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ out/
3939
### Kotlin ###
4040
.kotlin
4141

42-
*.env
42+
*.env
43+
firebase-adminsdk.json

gradle.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ googleApiClientVersion=2.0.0
44
jjwtVersion=0.12.6
55
mockitoKotlinVersion=5.4.0
66
springMockkVersion=4.0.2
7-
nimbusJwtVersion=10.3
7+
nimbusJwtVersion=10.3
8+
quartzVersion=2.5.0
9+
firebaseVersion=9.5.0

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
rootProject.name = "tuk-server"
22

3-
include("tuk-api")
3+
include("tuk-api", "tuk-batch")

tuk-batch/build.gradle.kts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
dependencies {
2+
implementation("org.springframework.boot:spring-boot-starter-web")
3+
implementation("org.springframework.boot:spring-boot-starter-actuator")
4+
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
5+
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
6+
implementation("org.jetbrains.kotlin:kotlin-reflect")
7+
8+
// quartz
9+
implementation("org.springframework.boot:spring-boot-starter-quartz:${project.properties["quartzVersion"]}")
10+
11+
// firebase
12+
implementation("com.google.firebase:firebase-admin:${project.properties["firebaseVersion"]}") // FCM Admin SDK
13+
14+
// mysql
15+
runtimeOnly("com.mysql:mysql-connector-j:${properties["mysqlVersion"]}")
16+
17+
// test
18+
testImplementation("org.springframework.boot:spring-boot-starter-test")
19+
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
20+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
21+
testRuntimeOnly("com.mysql:mysql-connector-j")
22+
testImplementation("org.mockito.kotlin:mockito-kotlin:${project.properties["mockitoKotlinVersion"]}")
23+
testImplementation("com.ninja-squad:springmockk:${project.properties["springMockkVersion"]}")
24+
}
25+
26+
tasks.withType<Test> {
27+
useJUnitPlatform()
28+
systemProperty("spring.profiles.active", "test")
29+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package nexters.tuk
2+
3+
import org.springframework.boot.autoconfigure.SpringBootApplication
4+
import org.springframework.boot.runApplication
5+
6+
@SpringBootApplication
7+
class TukBatchApplication
8+
9+
fun main(args: Array<String>) {
10+
runApplication<TukBatchApplication>(*args)
11+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package nexters.tuk.application.meeting
2+
3+
import nexters.tuk.application.meeting.dto.request.MeetingCommand
4+
import nexters.tuk.application.notification.MeetingNotifier
5+
import nexters.tuk.application.scheduler.MeetingNotificationScheduler
6+
import org.springframework.stereotype.Service
7+
8+
@Service
9+
class MeetingNotificationService(
10+
private val meetingNotifier: MeetingNotifier,
11+
private val meetingNotificationScheduler: MeetingNotificationScheduler
12+
) {
13+
fun handleMeetingNotification(command: MeetingCommand.Notification) {
14+
when (command) {
15+
is MeetingCommand.Notification.Tuk -> {
16+
meetingNotificationScheduler.scheduleTukNotification(command)
17+
}
18+
19+
is MeetingCommand.Notification.Invitation -> {
20+
meetingNotifier.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.meeting.dto.request
2+
3+
class MeetingCommand {
4+
sealed class Notification {
5+
data class Tuk(val meetingId: Long, val intervalDays: Long) : Notification()
6+
data class Invitation(val meetingId: Long, val purpose: String) : Notification()
7+
}
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package nexters.tuk.application.member
2+
3+
import org.springframework.stereotype.Service
4+
5+
@Service
6+
class MemberService {
7+
fun findTokensByMeetingId(meetingId: Long): List<String> {
8+
TODO("Not yet implemented")
9+
}
10+
}
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.meeting.dto.request.MeetingCommand
4+
import nexters.tuk.application.member.MemberService
5+
import org.springframework.stereotype.Service
6+
7+
8+
@Service
9+
class MeetingNotifier(
10+
private val memberService: MemberService,
11+
private val notificationSender: NotificationSender
12+
) {
13+
fun sendTukNotification(command: MeetingCommand.Notification.Tuk) {
14+
val tokens = memberService.findTokensByMeetingId(command.meetingId)
15+
val tukMessage = TukNotificationMessage(command.meetingId, command.intervalDays)
16+
17+
notificationSender.notifyMembers(tokens, tukMessage)
18+
}
19+
20+
fun sendInvitationNotification(command: MeetingCommand.Notification.Invitation) {
21+
val tokens = memberService.findTokensByMeetingId(command.meetingId)
22+
val invitationMessage = InvitationNotificationMessage(command.meetingId, command.purpose)
23+
24+
notificationSender.notifyMembers(tokens, invitationMessage)
25+
}
26+
}

0 commit comments

Comments
 (0)