From 8fa784c761723a511befe177b9dae7e2255c9f8e Mon Sep 17 00:00:00 2001 From: ziiyouth Date: Thu, 28 Dec 2023 01:10:53 +0900 Subject: [PATCH] =?UTF-8?q?[refactor]=20#6=20MailProvider=20=EC=9D=B8?= =?UTF-8?q?=EC=9E=90=EA=B0=92,=20=EB=A6=AC=ED=84=B4=EA=B0=92=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../checkmate/domain/member/service/MemberService.java | 3 ++- .../gachon/checkmate/global/config/mail/MailProvider.java | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/gachon/checkmate/domain/member/service/MemberService.java b/src/main/java/org/gachon/checkmate/domain/member/service/MemberService.java index e05c86b..5d27983 100644 --- a/src/main/java/org/gachon/checkmate/domain/member/service/MemberService.java +++ b/src/main/java/org/gachon/checkmate/domain/member/service/MemberService.java @@ -19,7 +19,8 @@ public class MemberService { private final MailProvider mailProvider; public EmailResponseDto sendMail(EmailPostRequestDto emailPostRequestDto) { - return mailProvider.sendMail(emailPostRequestDto, "email"); + String authNum = mailProvider.sendMail(emailPostRequestDto.email(), "email"); + return new EmailResponseDto(authNum); } } diff --git a/src/main/java/org/gachon/checkmate/global/config/mail/MailProvider.java b/src/main/java/org/gachon/checkmate/global/config/mail/MailProvider.java index 7f6060c..754a665 100644 --- a/src/main/java/org/gachon/checkmate/global/config/mail/MailProvider.java +++ b/src/main/java/org/gachon/checkmate/global/config/mail/MailProvider.java @@ -5,7 +5,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.gachon.checkmate.domain.member.dto.request.EmailPostRequestDto; -import org.gachon.checkmate.domain.member.dto.response.EmailResponseDto; import org.gachon.checkmate.global.error.exception.InternalServerException; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.MimeMessageHelper; @@ -25,16 +24,16 @@ public class MailProvider { private final JavaMailSender javaMailSender; private final SpringTemplateEngine templateEngine; - public EmailResponseDto sendMail(EmailPostRequestDto emailPostRequestDto, String type) { + public String sendMail(String email, String type) { String authNum = createNumericCode(); MimeMessage mimeMessage = javaMailSender.createMimeMessage(); try { MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, false, "UTF-8"); - mimeMessageHelper.setTo(emailPostRequestDto.email()); // 메일 수신자 + mimeMessageHelper.setTo(email); // 메일 수신자 mimeMessageHelper.setSubject("[CHECKMATE] 이메일 인증번호 발송"); // 메일 제목 mimeMessageHelper.setText(setContext(authNum, type), true); // 메일 본문 javaMailSender.send(mimeMessage); - return new EmailResponseDto(authNum); + return authNum; } catch (MessagingException e) { throw new InternalServerException(EMAIL_SEND_ERROR); }