Skip to content

Commit

Permalink
fix: 이벤트 리스터 인자 타입 수정 (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim0914 authored Jan 6, 2024
1 parent fc240b9 commit d6d27d1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.official.pium.notification.application;

import com.official.pium.petPlant.event.notification.NotificationEvent;
import java.util.List;
import com.official.pium.petPlant.event.notification.NotificationEvents;
import lombok.RequiredArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.*;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
Expand All @@ -15,8 +15,8 @@ public class NotificationEventListener {

@EventListener
@Async
public void handleNotificationEvents(List<NotificationEvent> notificationEvent) {
for (NotificationEvent event : notificationEvent) {
public void handleNotificationEvents(NotificationEvents notificationEvents) {
for (NotificationEvent event : notificationEvents.getNotificationEvents()) {
notificationService.sendNotification(event.getDeviceToken(), event.getTitle(), event.getBody());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.official.pium.petPlant.domain.PetPlant;
import com.official.pium.petPlant.event.history.HistoryEvent;
import com.official.pium.petPlant.event.notification.NotificationEvent;
import com.official.pium.petPlant.event.notification.NotificationEvents;
import com.official.pium.petPlant.repository.PetPlantRepository;
import java.time.LocalDate;
import java.util.List;
Expand Down Expand Up @@ -88,7 +89,7 @@ public void sendWaterNotification() {
.build()
).toList();

publisher.publishEvent(events);
publisher.publishEvent(NotificationEvents.from(events));
}

public void sendWaterNotificationTest() {
Expand All @@ -101,6 +102,6 @@ public void sendWaterNotificationTest() {
.build()
).toList();

publisher.publishEvent(events);
publisher.publishEvent(NotificationEvents.from(events));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.official.pium.petPlant.event.notification;

import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public class NotificationEvents {

private final List<NotificationEvent> notificationEvents;

public static NotificationEvents from(List<NotificationEvent> notificationEvents) {
return new NotificationEvents(notificationEvents);
}
}

0 comments on commit d6d27d1

Please sign in to comment.