diff --git a/src/main/java/com/tukorea/planding/domain/notify/dto/alarm/NotificationDTO.java b/src/main/java/com/tukorea/planding/domain/notify/dto/alarm/NotificationDTO.java index 48f5379..9d3b904 100644 --- a/src/main/java/com/tukorea/planding/domain/notify/dto/alarm/NotificationDTO.java +++ b/src/main/java/com/tukorea/planding/domain/notify/dto/alarm/NotificationDTO.java @@ -14,6 +14,7 @@ public class NotificationDTO { // 식별 ID private Long scheduleId; private String userCode; + private String title; private String message; private String url; private NotificationType notificationType; @@ -26,6 +27,7 @@ public class NotificationDTO { public static NotificationDTO createPersonalSchedule(String receiverCode, PersonalScheduleResponse response) { return NotificationDTO.builder() .scheduleId(response.id()) + .title(response.title()) .userCode(receiverCode) .message(response.content()) .url("/api/v1/schedule/" + response.id()) @@ -51,6 +53,7 @@ public static NotificationDTO createDailySchedule(String receiverCode, String me public static NotificationDTO createGroupSchedule(String receiverCode, Schedule response) { return NotificationDTO.builder() .scheduleId(response.getId()) + .title(response.getTitle()) .userCode(receiverCode) .message(response.getContent()) .url("/api/v1/schedule/" + response.getId()) diff --git a/src/main/java/com/tukorea/planding/domain/notify/entity/Notification.java b/src/main/java/com/tukorea/planding/domain/notify/entity/Notification.java index 9f1edd0..d48e1b2 100644 --- a/src/main/java/com/tukorea/planding/domain/notify/entity/Notification.java +++ b/src/main/java/com/tukorea/planding/domain/notify/entity/Notification.java @@ -23,7 +23,10 @@ public class Notification extends BaseEntity { private String userCode; - @Column(name = "scheduleCount") + @Column(name = "title") + private String title; + + @Column(name = "message") private String message; @Column(name = "group_name") @@ -43,8 +46,9 @@ public class Notification extends BaseEntity { private boolean isRead = false; @Builder - public Notification(String userCode, String message, String groupName, String url, NotificationType notificationType, LocalDate scheduleDate, boolean isRead) { + public Notification(String userCode,String title, String message, String groupName, String url, NotificationType notificationType, LocalDate scheduleDate, boolean isRead) { this.userCode = userCode; + this.title=title; this.message = message; this.groupName = groupName; this.url = url; diff --git a/src/main/java/com/tukorea/planding/domain/notify/service/fcm/FCMService.java b/src/main/java/com/tukorea/planding/domain/notify/service/fcm/FCMService.java index 452385a..e0aac23 100644 --- a/src/main/java/com/tukorea/planding/domain/notify/service/fcm/FCMService.java +++ b/src/main/java/com/tukorea/planding/domain/notify/service/fcm/FCMService.java @@ -2,18 +2,14 @@ import com.google.firebase.messaging.FirebaseMessaging; import com.google.firebase.messaging.Message; -import com.tukorea.planding.domain.group.entity.GroupRoom; import com.tukorea.planding.domain.notify.dto.alarm.DailyNotificationDto; import com.tukorea.planding.domain.notify.dto.alarm.NotificationDTO; import com.tukorea.planding.domain.notify.entity.NotificationType; -import com.tukorea.planding.domain.schedule.entity.Schedule; import com.tukorea.planding.domain.user.service.UserService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import static com.tukorea.planding.domain.schedule.entity.QSchedule.schedule; - @Service @Slf4j @RequiredArgsConstructor @@ -28,6 +24,7 @@ public void personalPublish(NotificationDTO notificationDTO) { Message message = Message.builder() .setToken(fcmToken) .putData("scheduleId", String.valueOf(notificationDTO.getScheduleId())) + .putData("title",notificationDTO.getTitle()) .putData("message", notificationDTO.getMessage()) .putData("date", notificationDTO.getDate()) .putData("url", notificationDTO.getUrl()) @@ -52,6 +49,7 @@ public void groupPublish(NotificationDTO notificationDTO) { Message message = Message.builder() .setToken(fcmToken) .putData("scheduleId", String.valueOf(notificationDTO.getScheduleId())) + .putData("title",notificationDTO.getTitle()) .putData("message", notificationDTO.getMessage()) .putData("date", notificationDTO.getDate()) .putData("url", notificationDTO.getUrl()) diff --git a/src/main/java/com/tukorea/planding/domain/notify/service/schedule/GroupScheduleNotificationHandler.java b/src/main/java/com/tukorea/planding/domain/notify/service/schedule/GroupScheduleNotificationHandler.java index 200c416..3271ac2 100644 --- a/src/main/java/com/tukorea/planding/domain/notify/service/schedule/GroupScheduleNotificationHandler.java +++ b/src/main/java/com/tukorea/planding/domain/notify/service/schedule/GroupScheduleNotificationHandler.java @@ -44,6 +44,7 @@ public void sendNotification(NotificationDTO request) { .groupName(request.getGroupName()) .notificationType(NotificationType.GROUP_SCHEDULE) .scheduleDate(LocalDate.parse(request.getDate())) + .title(request.getTitle()) .message(request.getMessage()) .url(request.getUrl()) .build(); diff --git a/src/main/java/com/tukorea/planding/domain/notify/service/schedule/PersonalScheduleNotificationHandler.java b/src/main/java/com/tukorea/planding/domain/notify/service/schedule/PersonalScheduleNotificationHandler.java index 5ff097a..fdfa81c 100644 --- a/src/main/java/com/tukorea/planding/domain/notify/service/schedule/PersonalScheduleNotificationHandler.java +++ b/src/main/java/com/tukorea/planding/domain/notify/service/schedule/PersonalScheduleNotificationHandler.java @@ -42,6 +42,7 @@ public void sendNotification(NotificationDTO request) { Notification notification = Notification.builder() .userCode(request.getUserCode()) + .title(request.getTitle()) .notificationType(NotificationType.PERSONAL_SCHEDULE) .scheduleDate(LocalDate.parse(request.getDate())) .message(request.getMessage()) diff --git a/src/main/java/com/tukorea/planding/domain/notify/service/sse/SseEmitterService.java b/src/main/java/com/tukorea/planding/domain/notify/service/sse/SseEmitterService.java index 5416efa..2fb1f34 100644 --- a/src/main/java/com/tukorea/planding/domain/notify/service/sse/SseEmitterService.java +++ b/src/main/java/com/tukorea/planding/domain/notify/service/sse/SseEmitterService.java @@ -1,6 +1,6 @@ package com.tukorea.planding.domain.notify.service.sse; -import com.tukorea.planding.domain.notify.dto.NotificationDTO; +import com.tukorea.planding.domain.notify.dto.alarm.NotificationDTO; import com.tukorea.planding.domain.notify.repository.EmitterRepositoryImpl; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -23,12 +23,14 @@ public SseEmitter createEmitter(String emitterKey) { } public void deleteEmitter(String emitterKey) { + log.info("emitter 삭제: {}",emitterKey); emitterRepository.deleteById(emitterKey); } - public void sendNotificationToClient(String emitterKey, NotificationDTO notificationDto) { + public void sendNotificationToClient(String emitterKey, NotificationDTO notificationDTO) { + log.info("sendNotificationToClient 동작 {}",emitterKey); emitterRepository.findById(emitterKey) - .ifPresent(emitter -> send(notificationDto, emitterKey, emitter)); + .ifPresent(emitter -> send(notificationDTO, emitterKey, emitter)); } public void send(Object data, String emitterKey, SseEmitter sseEmitter) {