-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat-be: 지원서 작성 완료 시 이메일 발송 기능 #960
base: be/develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
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) { | ||
|
||
log.info("시작"); | ||
Club club = event.club(); | ||
ApplyForm applyForm = event.applyForm(); | ||
Applicant applicant = event.applicant(); | ||
|
||
String subject = "지원 완료 안내"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제목에 동아리 이름도 넣어주는건 어떤가요? |
||
String content = String.format( | ||
"안녕하세요, %s님.\n\n%s 지원서가 성공적으로 제출되었습니다.\n\n감사합니다.", | ||
applicant.getName(), | ||
applyForm.getTitle() | ||
); | ||
|
||
emailService.send( | ||
club, | ||
applicant, | ||
subject, | ||
content, | ||
null | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,11 @@ | |
import com.cruru.applyform.controller.request.ApplyFormWriteRequest; | ||
import com.cruru.applyform.controller.response.ApplyFormResponse; | ||
import com.cruru.applyform.domain.ApplyForm; | ||
import com.cruru.applyform.domain.event.ApplyFormEvent; | ||
import com.cruru.applyform.exception.badrequest.ApplyFormSubmitOutOfPeriodException; | ||
import com.cruru.applyform.exception.badrequest.PersonalDataCollectDisagreeException; | ||
import com.cruru.applyform.service.ApplyFormService; | ||
import com.cruru.club.domain.Club; | ||
import com.cruru.dashboard.domain.Dashboard; | ||
import com.cruru.process.domain.Process; | ||
import com.cruru.process.service.ProcessService; | ||
|
@@ -22,6 +24,8 @@ | |
import java.util.List; | ||
import java.util.Objects; | ||
import lombok.RequiredArgsConstructor; | ||
import org.hibernate.Hibernate; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
|
@@ -35,6 +39,7 @@ public class ApplyFormFacade { | |
private final ProcessService processService; | ||
private final ApplicantService applicantService; | ||
private final AnswerService answerService; | ||
private final ApplicationEventPublisher applicationEventPublisher; | ||
private final Clock clock; | ||
|
||
public ApplyFormResponse readApplyFormById(long applyFormId) { | ||
|
@@ -68,6 +73,10 @@ public void submit(long applyFormId, ApplyFormSubmitRequest request) { | |
AnswerCreateRequest answerCreateRequest = getAnswerCreateRequest(question, answerCreateRequests); | ||
answerService.saveAnswerReplies(answerCreateRequest, question, applicant); | ||
} | ||
|
||
Club club = dashboard.getClub(); | ||
Hibernate.initialize(club); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 추후에 어떤 대상에게 보낸 이메일만 검색할 수 있는 기능을 넣는다면 현재 구조가 좋다고 생각하지만,, 추후의 유연성을 위해선 String 값인것도 좋을 것 같네요. |
||
applicationEventPublisher.publishEvent(new ApplyFormEvent(club, applyForm, applicant)); | ||
} | ||
|
||
private void validatePersonalDataCollection(ApplyFormSubmitRequest request) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트때 사용한 로그인가용??ㅋㅋ