diff --git a/pom.xml b/pom.xml index 0326a79..5510bbf 100644 --- a/pom.xml +++ b/pom.xml @@ -116,8 +116,15 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 17 // 사용하는 Java 버전에 맞게 변경합니다. + 17 // 사용하는 Java 버전에 맞게 변경합니다. + + - - diff --git a/src/main/java/com/bside/BSIDE/user/domain/EmailDto.java b/src/main/java/com/bside/BSIDE/user/domain/EmailDto.java new file mode 100644 index 0000000..c918e04 --- /dev/null +++ b/src/main/java/com/bside/BSIDE/user/domain/EmailDto.java @@ -0,0 +1,28 @@ +package com.bside.BSIDE.user.domain; + +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.Email; +import lombok.*; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +@JsonInclude(JsonInclude.Include.NON_NULL) // null 값 출력x +public class EmailDto { + @Schema(accessMode = Schema.AccessMode.READ_ONLY) + private String usrNo; + + @Schema(description = "사용자 이메일", example = "programmer_h@naver.com") + @Email + private String email; + + @Schema(description = "월간 고밍 받는 이메일", example = "programmer_h@naver.com") + private String sendEmail; + + @Schema(description = "월간 고밍 날짜", example = "2022-07") + private String date; + +} diff --git a/src/main/java/com/bside/BSIDE/user/service/EmailService.java b/src/main/java/com/bside/BSIDE/user/service/EmailService.java index de38070..32d91cf 100644 --- a/src/main/java/com/bside/BSIDE/user/service/EmailService.java +++ b/src/main/java/com/bside/BSIDE/user/service/EmailService.java @@ -3,6 +3,6 @@ public interface EmailService { String sendCodeMessage(String to)throws Exception; String sendTemporaryPassword(String to, String temporaryPassword)throws Exception; - void sendByMonth(String email, String date) throws Exception; + void sendByMonth(String email,String sendEmail, String date) throws Exception; void scheduleMonthlyEmail() throws Exception; } diff --git a/src/main/java/com/bside/BSIDE/user/service/EmailServiceImpl.java b/src/main/java/com/bside/BSIDE/user/service/EmailServiceImpl.java index 3272c5d..1db8cbf 100644 --- a/src/main/java/com/bside/BSIDE/user/service/EmailServiceImpl.java +++ b/src/main/java/com/bside/BSIDE/user/service/EmailServiceImpl.java @@ -142,7 +142,7 @@ public String sendTemporaryPassword(String to, String temporaryPassword) throws /* 월간고밍 페이지에서 ‘이메일로 보내기’ 버튼을 눌렀을 때 */ @Override - public void sendByMonth(String email, String date) throws Exception { + public void sendByMonth(String email,String sendEmail, String date) throws Exception { /* MimeMessage 생성 및 설정 */ MimeMessage message = emailSender.createMimeMessage(); @@ -151,7 +151,7 @@ public void sendByMonth(String email, String date) throws Exception { UserDto userdto = userService.getUserByEmail(email); String[] dateArr = date.split("-"); - helper.setTo(email); // 수신자 이메일 주소 + helper.setTo(sendEmail); // 수신자 이메일 주소 helper.setSubject("[Goming] " + userdto.getUsrNm() + "님의 월간고밍이 도착했어요!"); // 제목 List questionsAndAnswers = questionService.getQuestionsAndAnswersByMonthAndEmail(email, diff --git a/src/main/java/com/bside/BSIDE/user/web/EmailController.java b/src/main/java/com/bside/BSIDE/user/web/EmailController.java index 4730f18..cd0fb70 100644 --- a/src/main/java/com/bside/BSIDE/user/web/EmailController.java +++ b/src/main/java/com/bside/BSIDE/user/web/EmailController.java @@ -1,12 +1,9 @@ package com.bside.BSIDE.user.web; +import com.bside.BSIDE.user.domain.EmailDto; +import org.apache.ibatis.annotations.Param; import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import com.bside.BSIDE.user.service.EmailService; @@ -38,10 +35,14 @@ public String emailConfirm(@RequestParam String email) throws Exception { } /* 월간고밍 페이지에서 ‘이메일로 보내기’ 버튼을 눌렀을 때 */ - @GetMapping("/sendByMonth") + @PostMapping("/sendByMonth") @Operation(summary = "월간 고밍 이메일로 전송") - public void sendByMonth(@RequestParam String email, @RequestParam String date) throws Exception { - emailService.sendByMonth(email,date); + public void sendByMonth(@RequestBody EmailDto param) throws Exception { + System.out.println(param.getEmail()+"+ @#@#@##@#@#@#!@$@$!@$email"); + System.out.println(param.getSendEmail()+"+ @#@#@##@#@#@#!@$@$!@sendEmail"); + System.out.println(param.getDate()+ "+ @#@#@##@#@#@#!@$@$!@date"); + + emailService.sendByMonth(param.getEmail(),param.getSendEmail(),param.getDate()); } /* 월간 고밍 & 리마인드 메일 */