Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
58648bf
feat: google API 기능 추가
hodoon Feb 12, 2025
31f5121
feat: google API 기능 추가
hodoon Feb 12, 2025
40d8713
Merge branch 'feat/#14-1' into dev
hodoon Feb 12, 2025
ff4cfad
Merge remote-tracking branch 'origin/dev' into dev
hodoon Feb 12, 2025
82c0d1a
Merge branch 'dev' of https://github.com/DASOM-GitHub/dasom-web-backe…
hodoon Feb 13, 2025
db28bfc
feat: 메일 발송 기능 구현
hodoon Feb 18, 2025
52651c0
fix: 이메일 전송 관련 ErrorCode 수정
hodoon Feb 18, 2025
8e3cfac
Merge branch 'dev' into feat/#38-1
hodoon Feb 18, 2025
79d3fd5
feat: 서류 지원결과와 최종 합격 결과 API 나누기
hodoon Feb 18, 2025
6bc4251
Merge remote-tracking branch 'origin/feat/#38-1' into feat/#38-1
hodoon Feb 18, 2025
64e7268
fix: 서류 지원결과와 최종 합격 결과 API 하나의 메소드에서 지원되게 수정 MailType 열거형 추가
hodoon Feb 18, 2025
272bd01
fix: ApplicantServiceImpl의 sendEmailsToApplicants 메소드 ApplicantStatus…
hodoon Feb 18, 2025
526448a
test: ApplicantServiceImpl의 sendEmailsToApplicants 메소드 테스트 케이스 작성 및 E…
hodoon Feb 18, 2025
b0bf4ea
fix: EmailServiceTest에 들어가는 from의 value가 외부 환경변수를 인식하지 못하는 문제 발생 추후 테…
hodoon Feb 18, 2025
b834817
feat: EmailServiceTest 추가
hodoon Feb 19, 2025
99fa912
feat: 발송 이메일 템플릿 추가
hodoon Feb 24, 2025
d14ac26
Merge branch 'dev' into feat/#38-1
hodoon Feb 24, 2025
7f34032
fix: 발송 이메일 템플릿 수정
hodoon Feb 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions src/main/java/dmu/dasom/api/domain/email/service/EmailService.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,36 @@ public void sendEmail(String to, String name, MailType mailType) throws Messagin
}
// 메일 제목 및 템플릿 설정
String subject;
String templateName = switch (mailType) {
String emailContent;
String buttonUrl = "#";
String buttonText;
switch (mailType) {
case DOCUMENT_RESULT -> {
subject = "서류 합격 안내";
yield "document-pass-template";
subject = "동양미래대학교 컴퓨터소프트웨어공학과 전공 동아리 DASOM 서류 결과 안내";
emailContent = "먼저 다솜 34기에 많은 관심을 갖고 지원해 주셔서 감사드리며,<br>" +
"내부 서류 평가 결과 및 추후 일정에 관해 안내드리고자 이메일을 발송하게 되었습니다.<br>" +
"모집 폼 합/불합 결과는 아래 버튼 혹은 홈페이지를 통해 확인이 가능합니다.";
buttonText = "서류 결과 확인하기";
}
case FINAL_RESULT -> {
subject = "최종 합격 안내";
yield "final-pass-template";
subject = "동양미래대학교 컴퓨터소프트웨어공학과 전공 동아리 DASOM 최종 합격 안내";
emailContent = "먼저 다솜 34기에 많은 관심을 갖고 지원해 주셔서 감사드리며,<br>" +
"최종 면접 결과 및 추후 일정에 관해 안내드리고자 이메일을 발송하게 되었습니다.<br>" +
"모집 폼 합/불합 결과는 아래 버튼 혹은 홈페이지를 통해 확인이 가능합니다.";
buttonText = "최종 결과 확인하기";
}
default -> throw new IllegalStateException("Unexpected value: " + mailType);
};
}

// HTML 템플릿에 전달할 데이터 설정
Context context = new Context();
context.setVariable("name", name); // 지원자 이름 전달
context.setVariable("emailContent", emailContent); // 이메일 내용 전달
context.setVariable("buttonUrl", buttonUrl); // 버튼 링크 전달
context.setVariable("buttonText", buttonText);

// HTML 템플릿 처리
String htmlBody = templateEngine.process(templateName, context);
String htmlBody = templateEngine.process("email-template", context);

// 이메일 생성 및 전송
MimeMessage message = javaMailSender.createMimeMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import dmu.dasom.api.domain.recruit.service.RecruitService;
import dmu.dasom.api.domain.email.enums.MailType;
import dmu.dasom.api.global.dto.PageResponse;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
Expand Down
154 changes: 108 additions & 46 deletions src/main/resources/template/email-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,76 +3,138 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>지원 결과 확인</title>
<title>이메일 안내</title>
<link rel="stylesheet" as="style" crossorigin href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard.css" />
<style>
body {
font-family: Arial, sans-serif;
background-color: #1a1a1a;
color: #ffffff;
background-color: #17171B;
color: white;
font-family: 'Pretendard', sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
padding: 0;
}
.container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #1a1a1a;
border-radius: 8px;
text-align: center;

.email-container {
width: 740px;
height: 680px;
background: #17171B;
padding: 30px;
position: relative;
}
.header {
font-size: 24px;
font-weight: bold;
color: #00B493;

.logo {
display: flex;
justify-content: center;
position: relative;
margin-bottom: 20px;
}
.sub-header {
font-size: 16px;
background-color: #00B493;
padding: 10px;
border-radius: 5px;
margin-bottom: 20px;

.logo img {
width: 21px;
height: 24px;
border-radius: 3px;
}
.content {
font-size: 14px;
line-height: 1.8;

.divider {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
}
.content p {
margin-bottom: 10px;

.divider .line {
flex: 1;
border-top: 1px solid #00B493;
margin: 0 10px;
}
.highlight {

.title {
font-size: 48px;
font-weight: 900;
color: #00B493;
margin-bottom: 30px;
}

.greeting {
font-size: 20px;
font-weight: 600;
margin-bottom: 40px;
}

.content {
font-size: 16px;
font-weight: 400;
line-height: 2.5;
text-align: right;
margin-bottom: 40px;
}

.contact {
font-size: 16px;
font-weight: 400;
line-height: 1.5;
}

.button-container {
display: flex;
justify-content: flex-end;
margin-bottom: 40px;
}

.button {
display: inline-block;
background-color: #00B493;
color: #ffffff;
padding: 12px 24px;
background: #00B493;
color: white;
font-size: 16px;
font-weight: 400;
padding: 10px 20px;
border-radius: 5px;
display: flex;
align-items: center;
text-decoration: none;
font-size: 16px;
}

.button:hover {
background-color: #00B493;
background: #00987A;
}

.button .arrow {
border: solid white;
border-width: 0 2px 2px 0;
display: inline-block;
padding: 5px;
transform: rotate(-45deg);
margin-left: 10px;
}
</style>
</head>
<body>
<div class="container">
<!-- Header Section -->
<div class="header">DASOM</div>
<div class="email-container">
<div class="logo">
<div class="divider">
<div class="line"></div>
<img src="logo.png" alt="로고">
<div class="line"></div>
</div>
</div>

<!-- Sub-header Section -->
<div class="sub-header">컴퓨터소프트웨어공학과 전공동아리 다솜<br>34기 서류 합격자 조회</div>
<div class="title">DASOM</div>
<div class="greeting" th:text="${name} + '님 안녕하세요.'"></div>
<div>컴퓨터공학부 전공동아리 다솜입니다.</div>

<!-- Content Section -->
<div class="content">
<p>안녕하세요, <span class="highlight" th:text="${name}"></span>님.</p>
<p>학번 마지막 <span class="highlight">4자리</span> + 전화번호 마지막 <span class="highlight">4자리</span>를 입력하여<br>지원 결과를 확인할 수 있습니다.</p>
<p>예시) <span class="highlight">08470542</span></p>
<div class="content" th:utext="${emailContent}"></div>

<div class="button-container">
<a th:href="${buttonUrl}" class="button">
<span th:text="${buttonText}"></span> <span class="arrow"></span>
</a>
</div>

<!-- Button -->
<a href="https://example.com/result" class="button">결과 확인하기</a>
<div class="contact">
또한, 문의 사항은 본 메일에 회신 또는 아래 번호로 편하게 연락 부탁드립니다.<br>
010-6361-3481
</div>
</div>
</body>
Expand Down
Binary file added src/main/resources/template/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void sendEmail_documentResult() throws MessagingException {
String name = "지원자";
MailType mailType = MailType.DOCUMENT_RESULT;

String expectedTemplate = "document-pass-template";
String expectedTemplate = "email-template";
String expectedHtmlBody = "<html><body>Document Pass</body></html>";
when(templateEngine.process(eq(expectedTemplate), any(Context.class))).thenReturn(expectedHtmlBody);

Expand All @@ -76,7 +76,7 @@ void sendEmail_finalResult() throws MessagingException {
String name = "지원자";
MailType mailType = MailType.FINAL_RESULT;

String expectedTemplate = "final-pass-template";
String expectedTemplate = "email-template";
String expectedHtmlBody = "<html><body>Final Pass</body></html>";
when(templateEngine.process(eq(expectedTemplate), any(Context.class))).thenReturn(expectedHtmlBody);

Expand Down