Skip to content

Commit

Permalink
✨: feat 오늘의 질문 daily notification #33
Browse files Browse the repository at this point in the history
  • Loading branch information
sookyungg committed Mar 19, 2024
1 parent 12cdc0d commit ad090ec
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
12 changes: 7 additions & 5 deletions plu-api/src/main/kotlin/com/th/plu/api/PluApiApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ import com.th.plu.domain.PluDomainRoot
import com.th.plu.external.PluExternalRoot
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.scheduling.annotation.EnableScheduling

@EnableScheduling
@SpringBootApplication(scanBasePackageClasses = [
PluApiApplication::class,
PluDomainRoot::class,
PluCommonRoot::class,
PluExternalRoot::class
PluApiApplication::class,
PluDomainRoot::class,
PluCommonRoot::class,
PluExternalRoot::class
])
class PluApiApplication

fun main(args: Array<String>) {
runApplication<PluApiApplication>(*args)
runApplication<PluApiApplication>(*args)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.th.plu.api.controller.notification

import com.th.plu.api.controller.notification.dto.request.MessageSendRequest
import com.th.plu.api.service.notification.NotificationService
import com.th.plu.common.Slf4JKotlinLogging.log
import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Component

@Component
class ScheduledNotificationSender(private val notificationService: NotificationService) {
@Scheduled(cron = "0 0 22 * * ?")
fun sendDailyNotification() {
notificationService.sendMessageToAllMember(MessageSendRequest.DAILY_QUESTION_MESSAGE())
log.info { "오늘의 질문 알림을 보냈습니다." }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
package com.th.plu.api.controller.notification.dto.request

data class MessageSendRequest(var title: String, var body: String) {
companion object {
fun DAILY_QUESTION_MESSAGE() = MessageSendRequest(
title = "오늘의 질문 알림",
body = "오늘의 질문에 답할 시간입니다."
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import com.th.plu.common.PluCommonRoot
import com.th.plu.external.PluExternalRoot
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.scheduling.annotation.EnableScheduling

@EnableScheduling
@SpringBootApplication(scanBasePackageClasses = [
PluNotificationApplication::class,
PluCommonRoot::class,
PluExternalRoot::class
PluNotificationApplication::class,
PluCommonRoot::class,
PluExternalRoot::class
])
class PluNotificationApplication

fun main(args: Array<String>) {
runApplication<PluNotificationApplication>(*args)
runApplication<PluNotificationApplication>(*args)
}

0 comments on commit ad090ec

Please sign in to comment.