-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor/311 : 메일 발송 실패 트랜잭션 별도 관리 #423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ce7ba68
feat : 메일 로그 발송 실패 로그 트랜잭션 분리 코드 추가
crocusia 2e79fce
feat : 추가한 서비스 코드 AOP에 적용
crocusia 00b5304
feat : 메일 발송 성공 서비스 코드 추가
crocusia 1e1a042
Merge branch 'dev' of https://github.com/NBC-finalProject/CS25-BE int…
crocusia 70faaad
feat : 메일 성공 로그 저장 메서드 적용
crocusia 1ebf5c8
feat : 메일 발송 성공 로그 저장 실패 예외 처리 추가
crocusia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
47 changes: 47 additions & 0 deletions
47
cs25-batch/src/main/java/com/example/cs25batch/batch/service/MailLogBatchService.java
This file contains hidden or 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,47 @@ | ||
| package com.example.cs25batch.batch.service; | ||
|
|
||
| import com.example.cs25entity.domain.mail.entity.MailLog; | ||
| import com.example.cs25entity.domain.mail.enums.MailStatus; | ||
| import com.example.cs25entity.domain.mail.repository.MailLogRepository; | ||
| import com.example.cs25entity.domain.quiz.entity.Quiz; | ||
| import com.example.cs25entity.domain.subscription.entity.Subscription; | ||
| import java.time.LocalDateTime; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Propagation; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class MailLogBatchService { | ||
|
|
||
| private final MailLogRepository mailLogRepository; | ||
|
|
||
| @Transactional(propagation = Propagation.REQUIRES_NEW) | ||
| public void saveFailLog(Subscription subscription, | ||
| Quiz quiz, | ||
| LocalDateTime sendDateTime, | ||
| String cause) { | ||
| MailLog log = MailLog.builder() | ||
| .subscription(subscription) | ||
| .quiz(quiz) | ||
| .sendDate(sendDateTime) | ||
| .status(MailStatus.FAILED) | ||
| .caused(cause) | ||
| .build(); | ||
| mailLogRepository.save(log); | ||
| } | ||
crocusia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @Transactional | ||
| public void saveSuccessLog(Subscription subscription, | ||
| Quiz quiz, | ||
| LocalDateTime sendDateTime) { | ||
| mailLogRepository.save(MailLog.builder() | ||
| .subscription(subscription) | ||
| .quiz(quiz) | ||
| .sendDate(sendDateTime) | ||
| .status(MailStatus.SENT) | ||
| .caused(null) | ||
| .build()); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.