-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/develop' into refac…
…tor/#403-nana-pick # Conflicts: # src/main/java/com/jeju/nanaland/domain/nana/repository/NanaRepositoryCustom.java # src/main/java/com/jeju/nanaland/domain/nana/repository/NanaRepositoryImpl.java
- Loading branch information
Showing
93 changed files
with
3,122 additions
and
1,886 deletions.
There are no files selected for viewing
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
77 changes: 77 additions & 0 deletions
77
src/main/java/com/jeju/nanaland/domain/common/service/MailService.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,77 @@ | ||
package com.jeju.nanaland.domain.common.service; | ||
|
||
import static com.jeju.nanaland.global.exception.ErrorCode.MAIL_FAIL_ERROR; | ||
|
||
import com.jeju.nanaland.domain.report.entity.Report; | ||
import com.jeju.nanaland.global.exception.ServerErrorException; | ||
import jakarta.mail.Message.RecipientType; | ||
import jakarta.mail.MessagingException; | ||
import jakarta.mail.internet.InternetAddress; | ||
import jakarta.mail.internet.MimeMessage; | ||
import java.io.UnsupportedEncodingException; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.mail.javamail.JavaMailSender; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Service; | ||
import org.thymeleaf.context.Context; | ||
import org.thymeleaf.spring6.SpringTemplateEngine; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class MailService { | ||
|
||
// TODO: 관리자 계정으로 바꾸기 | ||
private static final String ADMIN_EMAIL = "[email protected]"; | ||
private final Environment env; | ||
private final JavaMailSender javaMailSender; | ||
private final SpringTemplateEngine templateEngine; | ||
|
||
/** | ||
* 메일 전송 | ||
* | ||
* @param report 요청 (InfoFixReport, ClaimReport) | ||
* @param urls 파일 URL 리스트 | ||
* @throws ServerErrorException 메일 전송이 실패한 경우 | ||
*/ | ||
@Async("mailExecutor") | ||
public void sendEmailReport(Report report, List<String> urls) { | ||
try { | ||
MimeMessage mimeMessage = createReportMail(report, urls); | ||
javaMailSender.send(mimeMessage); | ||
} catch (Exception e) { | ||
log.error(e.getMessage()); | ||
throw new ServerErrorException(MAIL_FAIL_ERROR.getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* 메일 생성 | ||
* | ||
* @param report 요청 (InfoFixReport, ClaimReport) | ||
* @param urls 파일 URL 리스트 | ||
* @return MimeMessage | ||
* @throws MessagingException 메일 관련 오류가 발생한 경우 | ||
* @throws UnsupportedEncodingException 인코딩 오류가 발생한 경우 | ||
*/ | ||
private MimeMessage createReportMail(Report report, List<String> urls) | ||
throws MessagingException, UnsupportedEncodingException { | ||
MimeMessage message = javaMailSender.createMimeMessage(); | ||
String senderEmail = env.getProperty("spring.mail.username"); | ||
message.setFrom(new InternetAddress(senderEmail, "Jeju in Nanaland")); | ||
message.setRecipients(RecipientType.TO, ADMIN_EMAIL); | ||
|
||
Context context = new Context(); | ||
String templateName = report.setReportContextAndGetTemplate(message, context); | ||
|
||
for (int i = 0; i < urls.size(); i++) { | ||
context.setVariable("image_" + i, urls.get(i)); | ||
} | ||
message.setText(templateEngine.process(templateName, context), "utf-8", "html"); | ||
|
||
return message; | ||
} | ||
} |
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
19 changes: 0 additions & 19 deletions
19
src/main/java/com/jeju/nanaland/domain/favorite/dto/FavoritePostCardDto.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.