- 
                Notifications
    
You must be signed in to change notification settings  - Fork 0
 
[Refactor]면접 예약 날짜 변경 기능 추가 #93
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
      
      
    The head ref may contain hidden characters: "DASOMBE-18-refactor-\uBA74\uC811-\uC608\uC57D-\uB0A0\uC9DC-\uBCC0\uACBD-\uAE30\uB2A5-\uCD94\uAC00"
  
     Merged
                    Changes from 3 commits
      Commits
    
    
            Show all changes
          
          
            8 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      c65998d
              
                DASOMBE-18 지원자 학번,이메일 확인후 면접 예약 및 날자 변경 기능(테스트 못해봄.)
              
              
                NADELYSS e8425b8
              
                DASOMBE-18 면접 지원자 예약 날짜 변경 테스트
              
              
                NADELYSS 4c5cc6f
              
                DASOMBE-18 이메일 인증
              
              
                NADELYSS 6d0e134
              
                DASOMBE-18 <피드백 반영. 추가 설명 표시. 인증코드 템플릿 반영>
              
              
                NADELYSS 6884171
              
                [refactor] DASOMBE-18 <에러 코드 명세 추가>
              
              
                NADELYSS f41a765
              
                [fix] DASOMBE-18 <에러 코드 conflict 수정>
              
              
                NADELYSS fd1b434
              
                Merge branch 'dev' into DASOMBE-18-refactor-면접-예약-날짜-변경-기능-추가
              
              
                hodoon 3c800e3
              
                refactor: 면접 예약 날짜 변경 기능 추가(DASOMBE-18)
              
              
                hodoon 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
    
  
  
    
              
  
    
      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
    
  
  
    
              
        
          
          
            96 changes: 96 additions & 0 deletions
          
          96 
        
  src/main/java/dmu/dasom/api/domain/email/service/EmailService.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,96 @@ | ||
| package dmu.dasom.api.domain.email.service; | ||
| 
     | 
||
| import dmu.dasom.api.domain.common.exception.CustomException; | ||
| import dmu.dasom.api.domain.common.exception.ErrorCode; | ||
| import dmu.dasom.api.domain.google.enums.MailType; | ||
| import jakarta.mail.MessagingException; | ||
| import jakarta.mail.internet.MimeMessage; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.mail.javamail.JavaMailSender; | ||
| import org.springframework.mail.javamail.MimeMessageHelper; | ||
| import org.springframework.stereotype.Service; | ||
| import org.thymeleaf.TemplateEngine; | ||
| import org.thymeleaf.context.Context; | ||
| 
     | 
||
| @RequiredArgsConstructor | ||
| @Service | ||
| public class EmailService { | ||
| 
     | 
||
| private final TemplateEngine templateEngine; | ||
| private final JavaMailSender javaMailSender; | ||
| 
     | 
||
| @Value("${spring.mail.username}") | ||
| private String from; | ||
| 
     | 
||
| public void sendVerificationEmail(String to, String name, String code) throws MessagingException { | ||
| String subject = "DASOM 면접 시간 변경을 위한 이메일 인증 코드 안내"; | ||
| String emailContent = "요청하신 인증 코드는 다음과 같습니다.<br>" + | ||
| "인증 코드: <strong>" + code + "</strong><br>" + | ||
| "해당 코드를 3분 내에 입력하여 인증을 완료해주세요."; | ||
| 
     | 
||
| Context context = new Context(); | ||
| context.setVariable("name", name); | ||
| context.setVariable("emailContent", emailContent); | ||
| context.setVariable("buttonUrl", "https://dmu-dasom.or.kr"); // Or some other relevant link | ||
| context.setVariable("buttonText", "다솜 홈페이지로 이동"); | ||
| 
     | 
||
| String htmlBody = templateEngine.process("email-template", context); | ||
| send(to, subject, htmlBody); | ||
| } | ||
| 
     | 
||
| public void sendEmail(String to, String name, MailType mailType) throws MessagingException { | ||
| if (mailType == null){ | ||
| throw new CustomException(ErrorCode.MAIL_TYPE_NOT_VALID); | ||
| } | ||
| 
     | 
||
| // 메일 제목 및 템플릿 설정 | ||
| String subject; | ||
| String emailContent; | ||
| String buttonUrl = "https://dmu-dasom.or.kr/recruit/result"; | ||
| String buttonText; | ||
| 
     | 
||
| switch (mailType) { | ||
| case DOCUMENT_RESULT -> { | ||
| subject = "동양미래대학교 컴퓨터소프트웨어공학과 전공 동아리 DASOM 서류 결과 안내"; | ||
| emailContent = "먼저 다솜 34기에 많은 관심을 두고 지원해 주셔서 감사드리며,<br>" + | ||
| "내부 서류 평가 결과 및 추후 일정에 관해 안내해드리고자 이메일을 발송하게 되었습니다.<br>" + | ||
| "서류 전형 결과는 아래 버튼 혹은 홈페이지를 통해 확인이 가능합니다."; | ||
| buttonText = "서류 결과 확인하기"; | ||
| } | ||
| case FINAL_RESULT -> { | ||
| subject = "동양미래대학교 컴퓨터소프트웨어공학과 전공 동아리 DASOM 최종 면접 결과 안내"; | ||
| emailContent = "먼저 다솜 34기에 많은 관심을 두고 지원해 주셔서 감사드리며,<br>" + | ||
| "최종 면접 결과 및 추후 일정에 관해 안내해드리고자 이메일을 발송하게 되었습니다.<br>" + | ||
| "최종 면접 결과는 아래 버튼 혹은 홈페이지를 통해 확인이 가능합니다."; | ||
| buttonText = "최종 결과 확인하기"; | ||
| } | ||
| default -> throw new IllegalStateException("Unexpected value: " + mailType); | ||
| } | ||
| 
     | 
||
| // HTML 템플릿에 전달할 데이터 설정 | ||
| Context context = new Context(); | ||
| context.setVariable("name", name); // 지원자 이름 전달 | ||
| context.setVariable("emailContent", emailContent); // 이메일 내용 전달 | ||
| context.setVariable("buttonUrl", buttonUrl); // 버튼 링크 전달 | ||
| context.setVariable("buttonText", buttonText); | ||
| 
     | 
||
| // HTML 템플릿 처리 | ||
| String htmlBody = templateEngine.process("email-template", context); | ||
| send(to, subject, htmlBody); | ||
| } | ||
| 
     | 
||
| private void send(String to, String subject, String htmlBody) throws MessagingException { | ||
| MimeMessage message = javaMailSender.createMimeMessage(); | ||
| MimeMessageHelper helper = new MimeMessageHelper(message, true, "UTF-8"); | ||
| 
     | 
||
| helper.setTo(to); | ||
| helper.setSubject(subject); | ||
| helper.setText(htmlBody, true); | ||
| helper.setFrom((from != null && !from.isEmpty()) ? from : "[email protected]"); | ||
| 
     | 
||
| message.setContent(htmlBody, "text/html; charset=utf-8"); | ||
| 
     | 
||
| javaMailSender.send(message); | ||
| } | ||
| } | 
  
    
      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
    
  
  
    
              
        
          
          
            59 changes: 59 additions & 0 deletions
          
          59 
        
  src/main/java/dmu/dasom/api/domain/interview/controller/InterviewController.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,59 @@ | ||
| package dmu.dasom.api.domain.interview.controller; | ||
| 
     | 
||
| import dmu.dasom.api.domain.applicant.entity.Applicant; | ||
| import dmu.dasom.api.domain.applicant.repository.ApplicantRepository; | ||
| import dmu.dasom.api.domain.common.exception.CustomException; | ||
| import dmu.dasom.api.domain.common.exception.ErrorCode; | ||
| import dmu.dasom.api.domain.email.service.EmailService; | ||
| import dmu.dasom.api.domain.interview.dto.InterviewReservationModifyRequestDto; | ||
| import dmu.dasom.api.domain.interview.dto.VerificationCodeRequestDto; | ||
| import dmu.dasom.api.domain.interview.service.InterviewService; | ||
| import dmu.dasom.api.global.util.VerificationCodeManager; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import jakarta.mail.MessagingException; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.*; | ||
| 
     | 
||
| import java.util.List; | ||
| import dmu.dasom.api.domain.interview.dto.InterviewReservationApplicantResponseDto; | ||
| 
     | 
||
| @Tag(name = "Interview", description = "면접 관련 API") | ||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/api/interview") | ||
| public class InterviewController { | ||
| 
     | 
||
| private final InterviewService interviewService; | ||
| private final ApplicantRepository applicantRepository; | ||
| private final VerificationCodeManager verificationCodeManager; | ||
| private final EmailService emailService; | ||
| 
     | 
||
| @Operation(summary = "면접 예약 수정을 위한 인증 코드 발송", description = "지원자의 학번을 받아 이메일로 인증 코드를 발송합니다.") | ||
| @PostMapping("/send-verification") | ||
| public ResponseEntity<Void> sendVerificationCode(@Valid @RequestBody VerificationCodeRequestDto request) throws MessagingException { | ||
| Applicant applicant = applicantRepository.findByStudentNo(request.getStudentNo()) | ||
| .orElseThrow(() -> new CustomException(ErrorCode.APPLICANT_NOT_FOUND)); | ||
| 
     | 
||
| String code = verificationCodeManager.generateAndStoreCode(applicant.getStudentNo()); | ||
| emailService.sendVerificationEmail(applicant.getEmail(), applicant.getName(), code); | ||
| 
     | 
||
| return ResponseEntity.ok().build(); | ||
| } | ||
| 
     | 
||
| @Operation(summary = "면접 예약 수정", description = "이메일로 발송된 인증 코드를 통해 인증 후, 면접 날짜 및 시간을 수정합니다.") | ||
| @PutMapping("/reservation/modify") | ||
| public ResponseEntity<Void> modifyInterviewReservation(@Valid @RequestBody InterviewReservationModifyRequestDto request) { | ||
| interviewService.modifyInterviewReservation(request); | ||
| return ResponseEntity.ok().build(); | ||
| } | ||
| 
     | 
||
| @Operation(summary = "모든 면접 지원자 목록 조회", description = "모든 면접 지원자의 상세 정보와 예약 정보를 조회합니다.") | ||
| @GetMapping("/applicants") | ||
| public ResponseEntity<List<InterviewReservationApplicantResponseDto>> getAllInterviewApplicants() { | ||
| List<InterviewReservationApplicantResponseDto> applicants = interviewService.getAllInterviewApplicants(); | ||
| return ResponseEntity.ok(applicants); | ||
| } | ||
| } | 
        
          
          
            37 changes: 37 additions & 0 deletions
          
          37 
        
  src/main/java/dmu/dasom/api/domain/interview/dto/InterviewReservationModifyRequestDto.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,37 @@ | ||
| package dmu.dasom.api.domain.interview.dto; | ||
| 
     | 
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.Email; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import jakarta.validation.constraints.Pattern; | ||
| import jakarta.validation.constraints.Size; | ||
| import lombok.*; | ||
| 
     | 
||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| @Schema(name = "InterviewReservationModifyRequestDto", description = "면접 예약 수정 요청 DTO") | ||
| public class InterviewReservationModifyRequestDto { | ||
| 
     | 
||
| @NotNull(message = "학번은 필수 값입니다.") | ||
| @Pattern(regexp = "^[0-9]{8}$", message = "학번은 8자리 숫자로 구성되어야 합니다.") | ||
| @Size(min = 8, max = 8) | ||
| @Schema(description = "지원자 학번", example = "20250001") | ||
| private String studentNo; | ||
| 
     | 
||
| @NotNull(message = "이메일은 필수 값입니다.") | ||
| @Email(message = "유효한 이메일 주소를 입력해주세요.") | ||
| @Size(max = 64) | ||
| @Schema(description = "지원자 이메일", example = "[email protected]") | ||
| private String email; | ||
| 
     | 
||
| @NotNull(message = "새로운 슬롯 ID는 필수 값입니다.") | ||
| @Schema(description = "새롭게 예약할 면접 슬롯의 ID", example = "2") | ||
| private Long newSlotId; | ||
| 
     | 
||
| @NotNull(message = "인증 코드는 필수 값입니다.") | ||
| @Schema(description = "이메일로 발송된 6자리 인증 코드", example = "123456") | ||
| private String verificationCode; | ||
| } | 
        
          
          
            17 changes: 17 additions & 0 deletions
          
          17 
        
  src/main/java/dmu/dasom/api/domain/interview/dto/VerificationCodeRequestDto.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,17 @@ | ||
| package dmu.dasom.api.domain.interview.dto; | ||
| 
     | 
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import jakarta.validation.constraints.Pattern; | ||
| import jakarta.validation.constraints.Size; | ||
| import lombok.Getter; | ||
| 
     | 
||
| @Getter | ||
| public class VerificationCodeRequestDto { | ||
| 
     | 
||
| @NotNull(message = "학번은 필수 값입니다.") | ||
| @Pattern(regexp = "^[0-9]{8}$", message = "학번은 8자리 숫자로 구성되어야 합니다.") | ||
| @Size(min = 8, max = 8) | ||
| @Schema(description = "지원자 학번", example = "20250001") | ||
| private String studentNo; | ||
| } | 
  
    
      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
    
  
  
    
              
        
          
          
            5 changes: 5 additions & 0 deletions
          
          5 
        
  src/main/java/dmu/dasom/api/domain/interview/repository/InterviewReservationRepository.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 | 
|---|---|---|
| @@ -1,10 +1,15 @@ | ||
| package dmu.dasom.api.domain.interview.repository; | ||
| 
     | 
||
| import dmu.dasom.api.domain.interview.entity.InterviewReservation; | ||
| import dmu.dasom.api.domain.applicant.entity.Applicant; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.stereotype.Repository; | ||
| 
     | 
||
| import java.util.Optional; | ||
| 
     | 
||
| @Repository | ||
| public interface InterviewReservationRepository extends JpaRepository<InterviewReservation, Long> { | ||
| boolean existsByReservationCode(String reservationCode); | ||
| Optional<InterviewReservation> findByReservationCode(String reservationCode); | ||
| Optional<InterviewReservation> findByApplicant(Applicant applicant); | ||
| } | 
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  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.