-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : 발급 티켓 입장 처리 시 이메일 전송 로직 추가 (#341)
* feat : 발급 티켓 입장 처리 시 이메일 전송 로직 추가 * fix : toString 추가 및 발급 티켓 상태 디폴트 값 추가
- Loading branch information
1 parent
4b3f96c
commit cafc2ec
Showing
14 changed files
with
298 additions
and
3 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
DuDoong-Api/src/main/java/band/gosrock/api/email/dto/IssuedTicketMailDTO.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,19 @@ | ||
package band.gosrock.api.email.dto; | ||
|
||
|
||
import band.gosrock.infrastructure.config.mail.dto.EmailEventInfo; | ||
import band.gosrock.infrastructure.config.mail.dto.EmailIssuedTicketInfo; | ||
import band.gosrock.infrastructure.config.mail.dto.EmailUserInfo; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public class IssuedTicketMailDTO { | ||
|
||
private final EmailUserInfo userInfo; | ||
|
||
private final EmailIssuedTicketInfo issuedTicketInfo; | ||
|
||
private final EmailEventInfo eventInfo; | ||
} |
37 changes: 37 additions & 0 deletions
37
...i/src/main/java/band/gosrock/api/email/handler/EntranceIssuedTicketEventEmailHandler.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 band.gosrock.api.email.handler; | ||
|
||
|
||
import band.gosrock.api.email.dto.IssuedTicketMailDTO; | ||
import band.gosrock.api.email.service.EntranceIssuedTicketEmailService; | ||
import band.gosrock.api.email.service.IssuedTicketMailInfoHelper; | ||
import band.gosrock.domain.common.events.issuedTicket.EntranceIssuedTicketEvent; | ||
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 EntranceIssuedTicketEventEmailHandler { | ||
|
||
private final IssuedTicketMailInfoHelper issuedTicketMailInfoHelper; | ||
|
||
private final EntranceIssuedTicketEmailService entranceIssuedTicketEmailService; | ||
|
||
@Async | ||
@TransactionalEventListener( | ||
classes = EntranceIssuedTicketEvent.class, | ||
phase = TransactionPhase.AFTER_COMMIT) | ||
public void handleEntranceIssuedTicketEvent( | ||
EntranceIssuedTicketEvent entranceIssuedTicketEvent) { | ||
log.info(entranceIssuedTicketEvent.getIssuedTicketNo() + "번 티켓 입장 처리 이메일 전송"); | ||
|
||
IssuedTicketMailDTO issuedTicketMailDTO = | ||
issuedTicketMailInfoHelper.execute(entranceIssuedTicketEvent.getIssuedTicketNo()); | ||
entranceIssuedTicketEmailService.execute(issuedTicketMailDTO); | ||
log.info("이메일 전송 성공"); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...ng-Api/src/main/java/band/gosrock/api/email/service/EntranceIssuedTicketEmailService.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,29 @@ | ||
package band.gosrock.api.email.service; | ||
|
||
|
||
import band.gosrock.api.email.dto.IssuedTicketMailDTO; | ||
import band.gosrock.infrastructure.config.mail.dto.EmailUserInfo; | ||
import band.gosrock.infrastructure.config.ses.AwsSesUtils; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.thymeleaf.context.Context; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class EntranceIssuedTicketEmailService { | ||
|
||
private final AwsSesUtils awsSesUtils; | ||
|
||
public void execute(IssuedTicketMailDTO issuedTicketMailDTO) { | ||
String subject = "[두둥] 입장 확인 알림드립니다."; | ||
Context context = new Context(); | ||
EmailUserInfo userInfo = issuedTicketMailDTO.getUserInfo(); | ||
|
||
context.setVariable("userInfo", userInfo); | ||
context.setVariable("issuedTicketInfo", issuedTicketMailDTO.getIssuedTicketInfo()); | ||
context.setVariable("eventInfo", issuedTicketMailDTO.getEventInfo()); | ||
|
||
awsSesUtils.singleEmailRequest( | ||
userInfo.getEmail(), subject, "entranceIssuedTicket", context); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
DuDoong-Api/src/main/java/band/gosrock/api/email/service/IssuedTicketMailInfoHelper.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,45 @@ | ||
package band.gosrock.api.email.service; | ||
|
||
|
||
import band.gosrock.api.email.dto.IssuedTicketMailDTO; | ||
import band.gosrock.common.annotation.Helper; | ||
import band.gosrock.domain.domains.event.adaptor.EventAdaptor; | ||
import band.gosrock.domain.domains.event.domain.Event; | ||
import band.gosrock.domain.domains.host.adaptor.HostAdaptor; | ||
import band.gosrock.domain.domains.host.domain.Host; | ||
import band.gosrock.domain.domains.issuedTicket.adaptor.IssuedTicketAdaptor; | ||
import band.gosrock.domain.domains.issuedTicket.domain.IssuedTicket; | ||
import band.gosrock.domain.domains.user.adaptor.UserAdaptor; | ||
import band.gosrock.domain.domains.user.domain.User; | ||
import band.gosrock.infrastructure.config.mail.dto.EmailEventInfo; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Helper | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class IssuedTicketMailInfoHelper { | ||
|
||
private final UserAdaptor userAdaptor; | ||
|
||
private final EventAdaptor eventAdaptor; | ||
|
||
private final IssuedTicketAdaptor issuedTicketAdaptor; | ||
|
||
private final HostAdaptor hostAdaptor; | ||
|
||
public IssuedTicketMailDTO execute(String issuedTicketNo) { | ||
IssuedTicket issuedTicket = issuedTicketAdaptor.queryByIssuedTicketNo(issuedTicketNo); | ||
User user = userAdaptor.queryUser(issuedTicket.getUserInfo().getUserId()); | ||
Event event = eventAdaptor.findById(issuedTicket.getEventId()); | ||
Host host = hostAdaptor.findById(event.getHostId()); | ||
return new IssuedTicketMailDTO( | ||
user.toEmailUserInfo(), | ||
issuedTicket.toEmailIssuedTicketInfo(), | ||
getEventInfo(event, host)); | ||
} | ||
|
||
private EmailEventInfo getEventInfo(Event event, Host host) { | ||
return new EmailEventInfo(host.getProfile().getName(), event.getEventBasic().getName()); | ||
} | ||
} |
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
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
21 changes: 21 additions & 0 deletions
21
...ture/src/main/java/band/gosrock/infrastructure/config/mail/dto/EmailIssuedTicketInfo.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,21 @@ | ||
package band.gosrock.infrastructure.config.mail.dto; | ||
|
||
|
||
import java.time.LocalDateTime; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public class EmailIssuedTicketInfo { | ||
|
||
private final String issuedTicketNo; | ||
|
||
private final String ticketName; | ||
|
||
private final LocalDateTime createdAt; | ||
|
||
private final String issuedTicketStatus; | ||
|
||
private final String money; | ||
} |
56 changes: 56 additions & 0 deletions
56
DuDoong-Infrastructure/src/main/resources/templates/entranceIssuedTicket.html
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,56 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html | ||
xmlns:th="http://www.thymeleaf.org" | ||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" | ||
xmlns="http://www.w3.org/1999/xhtml" | ||
layout:decorate="~{layouts/mailFormat}" | ||
> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title></title> | ||
<style> | ||
* { | ||
line-height: 150%; | ||
font-family: Pretendard ,AppleSDGothic, apple sd gothic neo, noto sans korean, | ||
noto sans korean regular, noto sans cjk kr, noto sans cjk, | ||
nanum gothic, malgun gothic, dotum, arial, helvetica, MS Gothic, | ||
sans-serif !important; | ||
mso-line-height-rule: exactly; | ||
line-height: 1.8; | ||
-ms-text-size-adjust: 100%; | ||
-webkit-text-size-adjust: 100%; | ||
word-break: break-word; | ||
} | ||
</style> | ||
</head> | ||
<body style="margin: 0; padding: 0"> | ||
<div layout:fragment="content"> | ||
<div th:replace="fragments/title :: title(title='티켓 입장 확인 안내')">divider</div> | ||
|
||
<div > | ||
<span >안녕하세요</span> | ||
<span th:text="${userInfo.name}" >이름</span> | ||
<span >님</span> | ||
<br /> | ||
<span th:text="${userInfo.name}" >이름</span> | ||
<span>님이 발급하신 </span> | ||
</div> | ||
<div th:replace="fragments/subTilte :: hostAndEventAndIssuedTicket(eventInfo=${eventInfo}, issuedTicketInfo=${issuedTicketInfo}, text=' 티켓이 입장 처리 되었습니다.')"> | ||
이벤트 및 발급 티켓 정보 | ||
</div> | ||
<div th:replace="fragments/issuedTicketInfo :: issuedTicketInfo(issuedTicketInfo=${issuedTicketInfo})"> | ||
발급 티켓 정보 | ||
</div> | ||
<span>즐거운 관람 되세요!</span> | ||
|
||
<div align="right"> | ||
<img width="163" style="" src="https://asset.dudoong.com/common/duduongs.png"/> | ||
</div> | ||
|
||
<div th:replace="fragments/button :: button(href='https://dudoong.com' , text='두둥 바로가기')"> | ||
button | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
48 changes: 48 additions & 0 deletions
48
DuDoong-Infrastructure/src/main/resources/templates/fragments/issuedTicketInfo.html
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,48 @@ | ||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"> | ||
<head> | ||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> | ||
<meta content="width=device-width, initial-scale=1.0" name="viewport" /> | ||
<title></title> | ||
<style> | ||
* { | ||
line-height: 150%; | ||
} | ||
</style> | ||
</head> | ||
<div th:fragment="issuedTicketInfo(issuedTicketInfo)" | ||
style=" | ||
overflow: hidden; | ||
padding: 0px; | ||
margin-top: 20px; | ||
border: 0; | ||
font-weight: bold; | ||
font-size: 14px; | ||
font-family: Pretendard , AppleSDGothic, apple sd gothic neo, noto sans korean, | ||
noto sans korean regular, noto sans cjk kr, noto sans cjk, nanum gothic, | ||
malgun gothic, dotum, arial, helvetica, MS Gothic, sans-serif !important; | ||
" | ||
> | ||
<div style="font-weight: bold; background: #F8F8FA; padding: 10px ; margin-top: 10px;margin-bottom: 10px"> | ||
<div > | ||
<span >티켓 번호 : </span> | ||
<span th:text="${issuedTicketInfo.issuedTicketNo}" >티켓 번호</span> | ||
</div> | ||
<div > | ||
<span >티켓명 : </span> | ||
<span th:text="${issuedTicketInfo.ticketName}" >티켓명</span> | ||
</div> | ||
<div > | ||
<span >발급 일시 : </span> | ||
<span th:text="${#temporals.format(issuedTicketInfo.createdAt, 'yyyy-MM-dd HH:mm')}" >발급 일시</span> | ||
</div> | ||
<div > | ||
<span >티켓 상태 : </span> | ||
<span th:text="${issuedTicketInfo.issuedTicketStatus}" >티켓 상태</span> | ||
</div> | ||
<div> | ||
<span>가격 : </span> | ||
<span th:text="${issuedTicketInfo.money}">가격</span> | ||
</div> | ||
</div> | ||
</div> | ||
</html> |
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