55import java .util .Map ;
66import java .util .stream .Collectors ;
77
8- import org .springframework .amqp .rabbit .core .RabbitTemplate ;
98import org .springframework .stereotype .Component ;
109import org .springframework .transaction .annotation .Transactional ;
1110
1514import server .yakssok .domain .medication_schedule .domain .repository .MedicationScheduleRepository ;
1615import server .yakssok .domain .notification .application .service .PushService ;
1716import server .yakssok .domain .notification .presentation .dto .NotificationDTO ;
18- import server .yakssok .global .infra .rabbitmq .properties .MedicationQueueProperties ;
1917
2018@ Component
2119@ RequiredArgsConstructor
2220public class MedicationRemindAlarmJob {
2321
2422 private final PushService pushService ;
2523 private final MedicationScheduleRepository medicationScheduleRepository ;
26- private final RabbitTemplate rabbitTemplate ;
27- private final MedicationQueueProperties medicationQueueProperties ;
2824 private final OverduePolicy overduePolicy ;
2925
3026 @ Transactional
@@ -38,13 +34,12 @@ public void sendNotTakenRemindMedicationAlarms() {
3834 notTakenSchedules .stream ().collect (Collectors .groupingBy (MedicationScheduleAlarmDto ::userId ));
3935 for (Map .Entry <Long , List <MedicationScheduleAlarmDto >> entry : byUser .entrySet ()) {
4036 MedicationScheduleAlarmDto schedule = entry .getValue ().get (0 );
41- sendToMedicationQueue ( NotificationDTO . fromNotTakenMedicationSchedule ( schedule ) );
37+ sendNotification ( schedule );
4238 }
4339 }
4440
45- private void sendToMedicationQueue (NotificationDTO notificationDTO ) {
46- String exchange = medicationQueueProperties .exchange ();
47- String routingKey = medicationQueueProperties .routingKey ();
48- rabbitTemplate .convertAndSend (exchange , routingKey , notificationDTO );
41+ private void sendNotification (MedicationScheduleAlarmDto schedule ) {
42+ NotificationDTO notificationDTO = NotificationDTO .fromMedicationSchedule (schedule );
43+ pushService .sendNotification (notificationDTO );
4944 }
5045}
0 commit comments