-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat-be: 지원서 작성 완료 시 이메일 발송 기능 (#960)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Leetaehoon <[email protected]>
- Loading branch information
1 parent
8397c42
commit d63a3b3
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
backend/src/main/java/com/cruru/applyform/domain/event/ApplyFormEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.cruru.applyform.domain.event; | ||
|
||
import com.cruru.applicant.domain.Applicant; | ||
import com.cruru.applyform.domain.ApplyForm; | ||
import com.cruru.club.domain.Club; | ||
|
||
public record ApplyFormEvent(Club club, ApplyForm applyForm, Applicant applicant) { | ||
} |
44 changes: 44 additions & 0 deletions
44
backend/src/main/java/com/cruru/applyform/domain/event/ApplyFormEventListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.cruru.applyform.domain.event; | ||
|
||
import com.cruru.applicant.domain.Applicant; | ||
import com.cruru.applyform.domain.ApplyForm; | ||
import com.cruru.club.domain.Club; | ||
import com.cruru.email.service.EmailService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.event.TransactionPhase; | ||
import org.springframework.transaction.event.TransactionalEventListener; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class ApplyFormEventListener { | ||
|
||
private final EmailService emailService; | ||
|
||
@Async | ||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
public void handleApplyFormEvent(ApplyFormEvent event) { | ||
|
||
Club club = event.club(); | ||
ApplyForm applyForm = event.applyForm(); | ||
Applicant applicant = event.applicant(); | ||
|
||
String subject = "지원 완료 안내"; | ||
String content = String.format( | ||
"안녕하세요, %s님.\n\n%s 지원서가 성공적으로 제출되었습니다.\n\n감사합니다.", | ||
applicant.getName(), | ||
applyForm.getTitle() | ||
); | ||
|
||
emailService.send( | ||
club, | ||
applicant, | ||
subject, | ||
content, | ||
null | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters