Skip to content

Commit fad81bb

Browse files
committed
feat(ApplyVolunteerApplyService): 봉사 신청 이벤트 발행
1 parent 822b3fa commit fad81bb

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
import static com.somemore.global.exception.ExceptionMessage.DUPLICATE_APPLICATION;
44
import static com.somemore.global.exception.ExceptionMessage.RECRUITMENT_NOT_OPEN;
55

6+
import com.somemore.global.common.event.ServerEventPublisher;
7+
import com.somemore.global.common.event.ServerEventType;
68
import com.somemore.global.exception.BadRequestException;
9+
import com.somemore.notification.domain.NotificationSubType;
710
import com.somemore.recruitboard.domain.RecruitBoard;
811
import com.somemore.recruitboard.usecase.query.RecruitBoardQueryUseCase;
912
import com.somemore.volunteerapply.domain.VolunteerApply;
1013
import com.somemore.volunteerapply.dto.request.VolunteerApplyCreateRequestDto;
14+
import com.somemore.volunteerapply.event.VolunteerApplyEvent;
1115
import com.somemore.volunteerapply.repository.VolunteerApplyRepository;
1216
import com.somemore.volunteerapply.usecase.ApplyVolunteerApplyUseCase;
1317
import java.util.UUID;
@@ -22,6 +26,7 @@ public class ApplyVolunteerApplyService implements ApplyVolunteerApplyUseCase {
2226

2327
private final VolunteerApplyRepository volunteerApplyRepository;
2428
private final RecruitBoardQueryUseCase recruitBoardQueryUseCase;
29+
private final ServerEventPublisher serverEventPublisher;
2530

2631
@Override
2732
public Long apply(VolunteerApplyCreateRequestDto requestDto, UUID volunteerId) {
@@ -33,6 +38,8 @@ public Long apply(VolunteerApplyCreateRequestDto requestDto, UUID volunteerId) {
3338
VolunteerApply apply = requestDto.toEntity(volunteerId);
3439
volunteerApplyRepository.save(apply);
3540

41+
publishVolunteerApplyEvent(apply, board);
42+
3643
return apply.getId();
3744
}
3845

@@ -50,4 +57,17 @@ private void validateDuplicatedApply(UUID volunteerId, RecruitBoard board) {
5057
throw new BadRequestException(DUPLICATE_APPLICATION);
5158
}
5259
}
60+
61+
private void publishVolunteerApplyEvent(VolunteerApply apply, RecruitBoard board) {
62+
VolunteerApplyEvent event = VolunteerApplyEvent.builder()
63+
.type(ServerEventType.NOTIFICATION)
64+
.subType(NotificationSubType.VOLUNTEER_APPLY)
65+
.volunteerId(apply.getVolunteerId())
66+
.volunteerApplyId(apply.getId())
67+
.centerId(board.getCenterId())
68+
.recruitBoardId(board.getId())
69+
.build();
70+
71+
serverEventPublisher.publish(event);
72+
}
5373
}

0 commit comments

Comments
 (0)