Skip to content

Commit 5e96c9f

Browse files
committed
refactor(VolunteerApplyStatusChangeEvent): 인자, 파라미터 정리
- oldStatus 추가. - 이벤트에 receiverId가 포함되는 것이 어색, volunteerId로 수정.
1 parent fd139e9 commit 5e96c9f

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/main/java/com/somemore/volunteerapply/event/VolunteerApplyStatusChangeEvent.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@SuperBuilder
1717
public class VolunteerApplyStatusChangeEvent extends ServerEvent<NotificationSubType> {
1818

19-
private final UUID receiverId;
19+
private final UUID volunteerId;
2020
private final Long volunteerApplyId;
2121
private final UUID centerId;
2222
private final Long recruitBoardId;
@@ -25,15 +25,15 @@ public class VolunteerApplyStatusChangeEvent extends ServerEvent<NotificationSub
2525

2626
@JsonCreator
2727
public VolunteerApplyStatusChangeEvent(
28-
@JsonProperty("receiverId") UUID receiverId,
28+
@JsonProperty("receiverId") UUID volunteerId,
2929
@JsonProperty("volunteerApplyId") Long volunteerApplyId,
3030
@JsonProperty("centerId") UUID centerId,
3131
@JsonProperty("recruitBoardId") Long recruitBoardId,
3232
@JsonProperty("oldStatus") ApplyStatus oldStatus,
3333
@JsonProperty("newStatus") ApplyStatus newStatus
3434
) {
3535
super(ServerEventType.NOTIFICATION, NotificationSubType.VOLUNTEER_APPLY_STATUS_CHANGE, LocalDateTime.now());
36-
this.receiverId = receiverId;
36+
this.volunteerId = volunteerId;
3737
this.volunteerApplyId = volunteerApplyId;
3838
this.centerId = centerId;
3939
this.recruitBoardId = recruitBoardId;

src/main/java/com/somemore/volunteerapply/service/ApproveVolunteerApplyService.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.somemore.notification.domain.NotificationSubType;
77
import com.somemore.recruitboard.domain.RecruitBoard;
88
import com.somemore.recruitboard.usecase.query.RecruitBoardQueryUseCase;
9+
import com.somemore.volunteerapply.domain.ApplyStatus;
910
import com.somemore.volunteerapply.domain.VolunteerApply;
1011
import com.somemore.volunteerapply.event.VolunteerApplyStatusChangeEvent;
1112
import com.somemore.volunteerapply.repository.VolunteerApplyRepository;
@@ -38,10 +39,11 @@ public void approve(Long id, UUID centerId) {
3839
validateWriter(recruitBoard, centerId);
3940
validateBoardStatus(recruitBoard);
4041

42+
ApplyStatus oldStatus = apply.getStatus();
4143
apply.changeStatus(APPROVED);
4244
volunteerApplyRepository.save(apply);
4345

44-
publishVolunteerApplyStatusChangeEvent(apply.getVolunteerId(), id, recruitBoard, apply);
46+
publishVolunteerApplyStatusChangeEvent(apply, recruitBoard, oldStatus);
4547
}
4648

4749
private VolunteerApply getVolunteerApply(Long id) {
@@ -63,14 +65,15 @@ private void validateBoardStatus(RecruitBoard recruitBoard) {
6365
}
6466
}
6567

66-
private void publishVolunteerApplyStatusChangeEvent(UUID receiverId, Long id, RecruitBoard recruitBoard, VolunteerApply apply) {
68+
private void publishVolunteerApplyStatusChangeEvent(VolunteerApply apply, RecruitBoard recruitBoard, ApplyStatus oldStatus) {
6769
VolunteerApplyStatusChangeEvent event = VolunteerApplyStatusChangeEvent.builder()
6870
.type(ServerEventType.NOTIFICATION)
6971
.subType(NotificationSubType.VOLUNTEER_APPLY_STATUS_CHANGE)
70-
.receiverId(receiverId)
71-
.volunteerApplyId(id)
72+
.volunteerId(apply.getVolunteerId())
73+
.volunteerApplyId(apply.getId())
7274
.centerId(recruitBoard.getCenterId())
7375
.recruitBoardId(recruitBoard.getId())
76+
.oldStatus(oldStatus)
7477
.newStatus(apply.getStatus())
7578
.build();
7679

0 commit comments

Comments
 (0)