-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8837cbe
commit 6a9ca9e
Showing
34 changed files
with
701 additions
and
111 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -36,7 +36,7 @@ out/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
.env | ||
server/.env | ||
.env.* | ||
|
||
*.xlsx | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
server/.gradle/7.6.1/executionHistory/executionHistory.lock
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
82 changes: 82 additions & 0 deletions
82
.../econovation/recruit/api/applicant/handler/ApplicantRegisterEventConfirmEmailHandler.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,82 @@ | ||
package com.econovation.recruit.api.applicant.handler; | ||
|
||
import com.econovation.recruit.api.card.usecase.BoardRegisterUseCase; | ||
import com.econovation.recruitdomain.domains.applicant.event.ApplicantRegisterEvent; | ||
import com.econovation.recruitdomain.domains.card.adaptor.CardAdaptor; | ||
import com.econovation.recruitdomain.domains.card.domain.Card; | ||
import com.econovation.recruitinfrastructure.mail.EmailSenderService; | ||
import com.econovation.recruitinfrastructure.mail.GoogleMailProperties; | ||
import com.econovation.recruitinfrastructure.slack.SlackMessageProvider; | ||
import com.econovation.recruitinfrastructure.slack.config.SlackProperties; | ||
import javax.mail.MessagingException; | ||
import javax.mail.internet.MimeMessage; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.mail.SimpleMailMessage; | ||
import org.springframework.mail.javamail.MimeMessageHelper; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Propagation; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.transaction.event.TransactionPhase; | ||
import org.springframework.transaction.event.TransactionalEventListener; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class ApplicantRegisterEventConfirmEmailHandler { | ||
private final GoogleMailProperties googleMailProperties; | ||
private final EmailSenderService emailSenderService; | ||
@Async | ||
@TransactionalEventListener( | ||
classes = ApplicantRegisterEvent.class, | ||
phase = TransactionPhase.AFTER_COMMIT) | ||
@Transactional(propagation = Propagation.REQUIRES_NEW) | ||
public void handle(ApplicantRegisterEvent applicantRegistEvent) { | ||
log.info("%s님의 지원서가 접수되었습니다.", applicantRegistEvent.getUserName()); | ||
try{ | ||
MimeMessage mimeMessage = emailSenderService.createMimeMessage(); | ||
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, "utf-8"); | ||
helper.setFrom(googleMailProperties.getUsername()); | ||
helper.setTo(applicantRegistEvent.getEmail()); | ||
helper.setSubject("[Econovation] 에코노베이션 지원서 접수 확인 메일"); | ||
helper.setText(generateConfirmRegisterEmailBody(applicantRegistEvent.getEmail(), applicantRegistEvent.getUserName()), true); | ||
emailSenderService.sendEmail(mimeMessage); | ||
} catch (MessagingException e) { | ||
log.error("메일 content 생성에 실패하였습니다.. {}", e.getMessage()); | ||
} | ||
} | ||
// | ||
// MimeMessage mimeMessage = generateConfirmRegisterEmail( | ||
// applicantRegistEvent.getEmail(), | ||
// applicantRegistEvent.getUserName()); | ||
// emailSenderService.sendEmail(mimeMessage); | ||
|
||
/* private SimpleMailMessage generateConfirmRegisterEmail( | ||
String email, String userName) { | ||
SimpleMailMessage message = emailSenderService. | ||
MimeMessageHelper helper = new MimeMessageHelper(message, "utf-8"); | ||
try { | ||
helper.setFrom(googleMailProperties.getUsername()); | ||
helper.setTo(email); | ||
helper.setSubject("[Econovation] 에코노베이션 지원서 접수 확인 메일"); | ||
helper.setText(generateConfirmRegisterEmailBody(email, userName), true); | ||
} catch (MessagingException e) { | ||
log.error("메일 content 생성에 실패하였습니다.. {}", e.getMessage()); | ||
} | ||
return message; | ||
}*/ | ||
|
||
private String generateConfirmRegisterEmailBody(String email, String userName) { | ||
return String.format( | ||
"안녕하세요 %s님,\n\n" | ||
+ "저희 에코노베이션에 지원해주셔서 진심으로 감사드립니다.\n\n" | ||
+ "귀하의 지원이 성공적으로 접수되었음을 알려드립니다. " | ||
+ "저희 팀은 지원서를 신중히 검토한 후, 빠른 시일 내에 연락드리겠습니다.\n\n" | ||
+ "혹시 궁금한 사항이 있으시면 언제든지 저희에게 연락주시기 바랍니다.\n\n" | ||
+ "다시 한번 감사의 말씀을 드리며, 좋은 결과가 있기를 바랍니다.\n\n" | ||
+ "감사합니다,\n" | ||
+ "- 에코노베이션 Recruit팀", | ||
userName); | ||
} | ||
} |
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
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
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
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
9 changes: 9 additions & 0 deletions
9
.../com/econovation/recruitdomain/domains/applicant/exception/AnswerEmptyFieldException.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,9 @@ | ||
package com.econovation.recruitdomain.domains.applicant.exception; | ||
|
||
import com.econovation.recruitcommon.exception.RecruitCodeException; | ||
import com.econovation.recruitdomain.domains.applicant.domain.Answer; | ||
|
||
public class AnswerEmptyFieldException extends RecruitCodeException { | ||
public static RecruitCodeException EXCEPTION = new AnswerEmptyFieldException(); | ||
private AnswerEmptyFieldException() {super(AnswerErrorCode.ANSWER_EMPTY_FIELD);} | ||
} |
37 changes: 37 additions & 0 deletions
37
.../main/java/com/econovation/recruitdomain/domains/applicant/exception/AnswerErrorCode.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,37 @@ | ||
package com.econovation.recruitdomain.domains.applicant.exception; | ||
|
||
import com.econovation.recruitcommon.annotation.ExplainError; | ||
import com.econovation.recruitcommon.exception.BaseErrorCode; | ||
import com.econovation.recruitcommon.exception.ErrorReason; | ||
import java.lang.reflect.Field; | ||
import java.util.Objects; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import static com.econovation.recruitcommon.consts.RecruitStatic.BAD_REQUEST; | ||
import static com.econovation.recruitcommon.consts.RecruitStatic.NOT_FOUND; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum AnswerErrorCode implements BaseErrorCode { | ||
ANSWER_NOT_FOUND(NOT_FOUND, "ANSWER_NOT_FOUND", "지원자를 찾을 수 없습니다."), | ||
ANSWER_EMPTY_FIELD(BAD_REQUEST, "ANSWER_400_0", "필수 입력값이 없습니다."), | ||
ANSWER_DUPLICATE_SUBMIT(BAD_REQUEST, "ANSWER_400_1", "이미 지원한 지원자입니다."), | ||
; | ||
|
||
private Integer status; | ||
private String code; | ||
private String reason; | ||
|
||
@Override | ||
public ErrorReason getErrorReason() { | ||
return ErrorReason.builder().reason(reason).code(code).status(status).build(); | ||
} | ||
|
||
@Override | ||
public String getExplainError() throws NoSuchFieldException { | ||
Field field = this.getClass().getField(this.name()); | ||
ExplainError annotation = field.getAnnotation(ExplainError.class); | ||
return Objects.nonNull(annotation) ? annotation.value() : this.getReason(); | ||
} | ||
} |
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
4 changes: 3 additions & 1 deletion
4
...va/com/econovation/recruitinfrastructure/ConfigurationInfrastructurePropertiesConfig.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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package com.econovation.recruitinfrastructure; | ||
|
||
import com.econovation.recruitinfrastructure.mail.GoogleMailProperties; | ||
import com.econovation.recruitinfrastructure.slack.config.SlackProperties; | ||
import com.econovation.recruitinfrastructure.slack.config.SlackTFProperties; | ||
import org.springframework.boot.autoconfigure.mail.MailProperties; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@EnableConfigurationProperties({SlackProperties.class, SlackTFProperties.class}) | ||
@EnableConfigurationProperties({SlackProperties.class, SlackTFProperties.class, GoogleMailProperties.class}) | ||
@Configuration | ||
public class ConfigurationInfrastructurePropertiesConfig {} |
30 changes: 30 additions & 0 deletions
30
...tructure/src/main/java/com/econovation/recruitinfrastructure/mail/EmailSenderService.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,30 @@ | ||
package com.econovation.recruitinfrastructure.mail; | ||
|
||
import java.util.Properties; | ||
import javax.mail.internet.MimeMessage; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.mail.SimpleMailMessage; | ||
import org.springframework.mail.javamail.JavaMailSender; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class EmailSenderService { | ||
@Autowired private JavaMailSender javaMailSender; | ||
@Autowired | ||
public EmailSenderService(JavaMailSender javaMailSender) { | ||
this.javaMailSender = javaMailSender; | ||
} | ||
@Async | ||
public void sendEmail(SimpleMailMessage email) { | ||
javaMailSender.send(email); | ||
} | ||
@Async | ||
public void sendEmail(MimeMessage email) { | ||
javaMailSender.send(email); | ||
} | ||
|
||
public MimeMessage createMimeMessage() { | ||
return javaMailSender.createMimeMessage(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...ucture/src/main/java/com/econovation/recruitinfrastructure/mail/GoogleMailProperties.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,17 @@ | ||
package com.econovation.recruitinfrastructure.mail; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.boot.context.properties.ConstructorBinding; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@ConstructorBinding | ||
@ConfigurationProperties(prefix = "spring.mail") | ||
public class GoogleMailProperties { | ||
private String host; | ||
private Integer port; | ||
private String username; | ||
private String password; | ||
} |
23 changes: 23 additions & 0 deletions
23
...t-Infrastructure/src/main/java/com/econovation/recruitinfrastructure/mail/MailConfig.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,23 @@ | ||
package com.econovation.recruitinfrastructure.mail; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.mail.javamail.JavaMailSenderImpl; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
public class MailConfig { | ||
private final GoogleMailProperties mailProperties; | ||
|
||
@Bean | ||
public JavaMailSenderImpl mailSender() { | ||
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl(); | ||
javaMailSender.setProtocol("smtp"); | ||
javaMailSender.setHost(mailProperties.getHost()); | ||
javaMailSender.setPort(mailProperties.getPort()); | ||
javaMailSender.setUsername(mailProperties.getUsername()); | ||
javaMailSender.setPassword(mailProperties.getPassword()); | ||
return javaMailSender; | ||
} | ||
} |
Oops, something went wrong.