Skip to content

Commit

Permalink
Merge branch 'questionAnswer' of https://github.com/bsideproject/14_3_BE
Browse files Browse the repository at this point in the history
 into questionAnswer
  • Loading branch information
programmerDH-github committed Jul 20, 2023
2 parents 150fabf + 5c21cc0 commit 8b24c9f
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 14 deletions.
11 changes: 9 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,15 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source> // 사용하는 Java 버전에 맞게 변경합니다.
<target>17</target> // 사용하는 Java 버전에 맞게 변경합니다.
</configuration>
</plugin>
</plugins>

</build>

</project>
28 changes: 28 additions & 0 deletions src/main/java/com/bside/BSIDE/user/domain/EmailDto.java
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]")
@Email
private String email;

@Schema(description = "월간 고밍 받는 이메일", example = "[email protected]")
private String sendEmail;

@Schema(description = "월간 고밍 날짜", example = "2022-07")
private String date;

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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<QuestionAndAnswerDto> questionsAndAnswers = questionService.getQuestionsAndAnswersByMonthAndEmail(email,
Expand Down
19 changes: 10 additions & 9 deletions src/main/java/com/bside/BSIDE/user/web/EmailController.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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());
}

/* 월간 고밍 & 리마인드 메일 */
Expand Down

0 comments on commit 8b24c9f

Please sign in to comment.