Skip to content

Commit

Permalink
Merge pull request #615 from JNU-econovation/feat/#612
Browse files Browse the repository at this point in the history
[BE/FEAT] 회원탈퇴시 이메일 발송
  • Loading branch information
hwangdaesun authored Jan 8, 2025
2 parents fdc5bff + 0eaf22e commit 21d42fe
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/com/gaebaljip/exceed/common/MailTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
public class MailTemplate {
public static final String SIGN_UP_TEMPLATE = "signup";
public static final String FIND_PASSWORD_TEMPLATE = "findPassword";

public static final String WITHDRAW_TEMPLATE = "withdraw";
public static final String SIGN_UP_TITLE = "Eatceed 회원가입 인증 메일";
public static final String FIND_PASSWORD_TITLE = "Eatceed 비밀번호 찾기 메일";

public static final String SIGN_UP_MAIL_CONTEXT = "signupLink";
public static final String WITHDRAW_TITLE = "회원 탈퇴 완료 안내";
public static final String POLICY_MAIL_CONTEXT = "policyLink";
public static final String CONTACT_MAIL_CONTEXT = "contactEmail";
public static final String FIND_PASSWORD_MAIL_CONTEXT = "findPasswordLink";
public static final String SIGN_UP_CODE = "code";
public static final String SIGN_UP_EMAIL = "email";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import java.util.List;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.thymeleaf.context.Context;

import com.gaebaljip.exceed.application.domain.food.FoodEntity;
import com.gaebaljip.exceed.application.domain.meal.MealEntity;
Expand All @@ -15,8 +17,10 @@
import com.gaebaljip.exceed.application.port.out.food.FoodPort;
import com.gaebaljip.exceed.application.port.out.meal.MealFoodPort;
import com.gaebaljip.exceed.application.port.out.meal.MealPort;
import com.gaebaljip.exceed.application.port.out.member.EmailPort;
import com.gaebaljip.exceed.application.port.out.member.HistoryPort;
import com.gaebaljip.exceed.application.port.out.notify.NotifyPort;
import com.gaebaljip.exceed.common.MailTemplate;
import com.gaebaljip.exceed.common.event.DeleteMemberEvent;

import lombok.RequiredArgsConstructor;
Expand All @@ -29,6 +33,13 @@ public class DeleteMemberEventListener {
private final MealPort mealPort;
private final MealFoodPort mealFoodPort;
private final NotifyPort notifyPort;
private final EmailPort emailPort;

@Value("${exceed.deepLink.policy}")
private String POLICY_URL;

@Value("${exceed.contact.email}")
private String CONTACT_EMAIL;

@EventListener(classes = DeleteMemberEvent.class)
@Transactional
Expand All @@ -38,6 +49,7 @@ public void handle(DeleteMemberEvent event) {
foodPort.deleteByAllByIdInQuery(findFIdsByMemberEntity(event.getMemberEntity()));
historyPort.deleteByAllByIdInQuery(findHIdsByMemberEntity(event.getMemberEntity()));
notifyPort.deleteByAllByIdInQuery(findNIdsByMemberEntity(event.getMemberEntity()));
sendEmail(event.getMemberEntity());
}

private List<Long> findNIdsByMemberEntity(MemberEntity memberEntity) {
Expand All @@ -64,4 +76,15 @@ private List<Long> findHIdsByMemberEntity(MemberEntity memberEntity) {
List<HistoryEntity> historyEntities = historyPort.findByMemberEntity(memberEntity);
return historyEntities.stream().map(HistoryEntity::getId).toList();
}

private void sendEmail(MemberEntity memberEntity) {
Context context = new Context();
context.setVariable(MailTemplate.POLICY_MAIL_CONTEXT, POLICY_URL);
context.setVariable(MailTemplate.CONTACT_MAIL_CONTEXT, CONTACT_EMAIL);
emailPort.sendEmail(
memberEntity.getEmail(),
MailTemplate.WITHDRAW_TITLE,
MailTemplate.WITHDRAW_TEMPLATE,
context);
}
}
3 changes: 3 additions & 0 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ exceed:
deepLink :
signUp: eatceed://checkemail
updatePassword: eatceed://changepw
policy: ${EXCEED_POLICY_URL}
contact:
email: ${EXCEED_CONTACT_EMAIL}

springdoc:
api-docs:
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ exceed:
deepLink :
signUp : eatceed://checkemail
updatePassword : eatceed://changepw
policy: ${EXCEED_POLICY_URL}
contact:
email: ${EXCEED_CONTACT_EMAIL}

# swagger
springdoc:
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ exceed:
deepLink :
signUp: eatceed://checkemail
updatePassword: eatceed://changepw
policy: ${EXCEED_POLICY_URL}
contact:
email: ${EXCEED_CONTACT_EMAIL}

springdoc:
api-docs:
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ exceed:
deepLink :
signUp: eatceed://checkemail
updatePassword: eatceed://changepw
policy: eatceed://policy
contact:
email: [email protected]


encryption:
Expand Down
77 changes: 77 additions & 0 deletions src/main/resources/templates/withdraw.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>회원 탈퇴 완료</title>
<style>
/* 기본 스타일 */
body {
font-family: Arial, sans-serif;
background-color: #f9f9f9;
margin: 0;
padding: 0;
}
.email-container {
max-width: 600px;
margin: 20px auto;
background-color: #ffffff;
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 20px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
text-align: center;
}
.email-header {
font-size: 20px;
font-weight: bold;
color: #333333;
margin-bottom: 10px;
}
.email-body {
font-size: 16px;
line-height: 1.5;
color: #555555;
margin-bottom: 20px;
}
.email-footer {
font-size: 12px;
color: #999999;
margin-top: 20px;
text-align: center;
}
.highlight {
font-weight: bold;
color: #007bff;
}
.link {
color: #007bff;
text-decoration: none;
font-weight: bold;
}
</style>
</head>
<body>
<div class="email-container">
<!-- 헤더 -->
<div class="email-header">회원 탈퇴 완료 안내</div>

<!-- 본문 -->
<div class="email-body">
안녕하세요, <strong>[EATceed]</strong> 팀입니다.<br><br>
회원님의 탈퇴 요청이 정상적으로 처리되었음을 안내드립니다.<br><br>
회원 탈퇴에 따라 회원님의 개인정보는 <a th:href="${policyLink}" class="link">개인정보 처리방침</a>에 명시된 바에 따라 처리 및 삭제되었습니다.<br><br>
서비스 이용 중 불편함을 느끼셨다면, 언제든 의견을 남겨주시면 개선에 참고하겠습니다.<br><br>
추가 문의 사항이 있으시면 아래 이메일로 연락 주시기 바랍니다.<br>
<strong><a th:href="'mailto:' + ${contactEmail}" th:text="${contactEmail}" class="link"></a></strong> <br><br>
감사합니다.<br>
<strong>[EATceed]</strong> 팀 드림
</div>

<!-- 푸터 -->
<div class="email-footer">
이 이메일은 회원 탈퇴 요청에 따라 발송되었습니다.<br>
</div>
</div>
</body>
</html>

0 comments on commit 21d42fe

Please sign in to comment.