Skip to content

Commit 5a936c0

Browse files
committed
merge: dev
2 parents 8a1bd93 + 1e86007 commit 5a936c0

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.ivory.ivory.domain;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Builder;
5+
import lombok.Getter;
6+
import lombok.Setter;
7+
8+
@AllArgsConstructor
9+
@Getter
10+
@Setter
11+
@Builder
12+
public class NotificationMessage {
13+
private String message;
14+
private String childName;
15+
private String startDate;
16+
17+
}

src/main/java/com/ivory/ivory/service/CaregiverService.java

+21-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.ivory.ivory.service;
22

3+
import com.fasterxml.jackson.databind.ObjectMapper;
34
import com.ivory.ivory.domain.*;
45
import com.ivory.ivory.dto.CareDetailDto;
56
import com.ivory.ivory.dto.CareDto;
@@ -128,11 +129,27 @@ public CustomApiResponse<?> AcceptCare(Long currentMemberId, Long applyId) {
128129

129130
// 사용자에게 알림 전송
130131
String notificationMessage = "돌보미가 정해졌어요!";
132+
String childName = apply.getChild().getName();
133+
String startDate = apply.getStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
134+
135+
NotificationMessage message = NotificationMessage.builder()
136+
.message(notificationMessage)
137+
.childName(childName)
138+
.startDate(startDate)
139+
.build();
140+
141+
try {
142+
ObjectMapper objectMapper = new ObjectMapper();
143+
String notificationJson = objectMapper.writeValueAsString(message);
144+
145+
messagingTemplate.convertAndSend(
146+
"/topic/notifications/users/" + apply.getMember().getId().toString(),
147+
notificationJson
148+
);
149+
} catch (Exception e) {
150+
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "알림 전송 중 문제가 발생했습니다.", e);
151+
}
131152

132-
messagingTemplate.convertAndSend(
133-
"/topic/notifications/users/" + apply.getMember().getId().toString(), // 모든 구독자가 받을 수 있는 브로드캐스트 경로
134-
notificationMessage
135-
);
136153

137154
return CustomApiResponse.createSuccess(HttpStatus.OK.value(), "돌봄이 매칭되었습니다.", null);
138155
}

0 commit comments

Comments
 (0)