Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
refactor: Events 객체 컬랙션 래핑
Browse files Browse the repository at this point in the history
  • Loading branch information
goldentrash committed Feb 1, 2024
1 parent 27b6212 commit d61ff92
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class WaterCycleEventListener(

@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
@Async
fun sendFcmNotification(events: List<WaterCycleEvent>) {
val messages: List<Message> = createMessages(events, FCMChannel.WATER_ALERT.name)
fun sendFcmNotification(events: WaterCycleEvents) {
val messages: List<Message> = createMessages(events.plantsNeedWateredToday, FCMChannel.WATER_ALERT.name)

try {
firebaseMessaging.sendEach(messages)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package gdsc.plantory.event.notification

data class WaterCycleEvents(
val plantsNeedWateredToday: List<WaterCycleEvent>
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gdsc.plantory.plant.service

import gdsc.plantory.event.Events
import gdsc.plantory.event.notification.WaterCycleEvent
import gdsc.plantory.event.notification.WaterCycleEvents
import gdsc.plantory.plant.domain.CompanionPlantRepository
import gdsc.plantory.plant.presentation.dto.CompanionPlantWaterCycleDto
import org.springframework.scheduling.annotation.Scheduled
Expand All @@ -18,7 +19,7 @@ class ReminderService(
@Scheduled(cron = "0 0 8 * * *")
fun sendWaterNotification() {
val companionPlants = companionPlantRepository.findAllByNextWaterDate(LocalDate.now())
val events: List<WaterCycleEvent> = buildWaterCycleEvents(companionPlants)
val events = WaterCycleEvents(buildWaterCycleEvents(companionPlants))
Events.raise(events)
}

Expand Down

0 comments on commit d61ff92

Please sign in to comment.