Skip to content

Commit bb1031c

Browse files
committed
feat(MessageConverter): buildVolunteerReviewRequestNotification 추가
- buildVolunteerApplyStatusChangeNotification 와 형태가 비슷해서 리팩토링 예정. - createVolunteerApplyStatusChangeNotificationTitle dafault를 명확하게 예외로 처리.
1 parent 8fc0e8b commit bb1031c

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed
Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package com.somemore.notification.converter;
22

3+
import com.fasterxml.jackson.core.JsonProcessingException;
34
import com.fasterxml.jackson.databind.JsonNode;
45
import com.fasterxml.jackson.databind.ObjectMapper;
6+
import com.somemore.facade.event.VolunteerReviewRequestEvent;
57
import com.somemore.notification.domain.Notification;
68
import com.somemore.notification.domain.NotificationSubType;
79
import com.somemore.volunteerapply.domain.ApplyStatus;
8-
import com.somemore.volunteerapply.domain.VolunteerApplyStatusChangeEvent;
10+
import com.somemore.volunteerapply.event.VolunteerApplyStatusChangeEvent;
911
import lombok.RequiredArgsConstructor;
1012
import lombok.extern.slf4j.Slf4j;
1113
import org.springframework.stereotype.Component;
@@ -24,7 +26,7 @@ public Notification from(String message) {
2426

2527
return switch (NotificationSubType.from(eventType)) {
2628
case NOTE_BLAH_BLAH -> throw new UnsupportedOperationException("NOTE 알림 타입 처리 로직 미구현");
27-
case REVIEW_BLAH_BLAH -> throw new UnsupportedOperationException("REVIEW 알림 타입 처리 로직 미구현");
29+
case VOLUNTEER_REVIEW_REQUEST -> buildVolunteerReviewRequestNotification(message);
2830
case VOLUNTEER_APPLY_STATUS_CHANGE -> buildVolunteerApplyStatusChangeNotification(message);
2931
};
3032
} catch (Exception e) {
@@ -33,32 +35,40 @@ public Notification from(String message) {
3335
}
3436
}
3537

38+
private Notification buildVolunteerReviewRequestNotification(String message) throws JsonProcessingException {
39+
VolunteerReviewRequestEvent event = objectMapper.readValue(message, VolunteerReviewRequestEvent.class);
40+
41+
return Notification.builder()
42+
.receiverId(event.getVolunteerId())
43+
.title(createVolunteerReviewRequestNotificationTitle())
44+
.type(NotificationSubType.VOLUNTEER_REVIEW_REQUEST)
45+
.relatedId(event.getRecruitBoardId())
46+
.build();
47+
}
48+
3649
private Notification buildVolunteerApplyStatusChangeNotification(String message) throws Exception {
3750
VolunteerApplyStatusChangeEvent event = objectMapper.readValue(message, VolunteerApplyStatusChangeEvent.class);
3851

3952
return Notification.builder()
40-
.receiverId(event.getReceiverId())
41-
.title(buildNotificationTitle(event.getNewStatus()))
53+
.receiverId(event.getVolunteerId())
54+
.title(createVolunteerApplyStatusChangeNotificationTitle(event.getNewStatus()))
4255
.type(NotificationSubType.VOLUNTEER_APPLY_STATUS_CHANGE)
4356
.relatedId(event.getRecruitBoardId())
4457
.build();
4558
}
4659

47-
private Notification handleNoteEvent(String message) {
48-
// TODO: NOTE 이벤트를 처리하는 로직 구현
49-
throw new UnsupportedOperationException("NOTE 알림 타입 처리 로직 미구현");
50-
}
51-
52-
private Notification handleReviewEvent(String message) {
53-
// TODO: System 이벤트를 처리하는 로직 구현
54-
throw new UnsupportedOperationException("REVIEW 알림 타입 처리 로직 미구현");
60+
private String createVolunteerReviewRequestNotificationTitle() {
61+
return "최근 활동하신 활동의 후기를 작성해 주세요!";
5562
}
5663

57-
private String buildNotificationTitle(ApplyStatus newStatus) {
64+
private String createVolunteerApplyStatusChangeNotificationTitle(ApplyStatus newStatus) {
5865
return switch (newStatus) {
5966
case APPROVED -> "봉사 활동 신청이 승인되었습니다.";
6067
case REJECTED -> "봉사 활동 신청이 거절되었습니다.";
61-
default -> "봉사 활동 신청 상태가 변경되었습니다.";
68+
default -> {
69+
log.error("올바르지 않은 봉사 신청 상태입니다: {}", newStatus);
70+
throw new IllegalArgumentException();
71+
}
6272
};
6373
}
6474
}

0 commit comments

Comments
 (0)