-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ff2ee7
commit ec4903f
Showing
6 changed files
with
95 additions
and
1 deletion.
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
27 changes: 27 additions & 0 deletions
27
src/main/java/kr/co/studyhubinu/studyhubserver/emailTest/EmailTestController.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,27 @@ | ||
package kr.co.studyhubinu.studyhubserver.emailTest; | ||
|
||
import kr.co.studyhubinu.studyhubserver.email.dto.request.MailValidRequest; | ||
import kr.co.studyhubinu.studyhubserver.email.dto.response.ValidEmailResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import javax.validation.Valid; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api") | ||
public class EmailTestController { | ||
|
||
private final EmailTestService emailTestService; | ||
|
||
@PostMapping("/v1/email/verify-test") | ||
public ResponseEntity<ValidEmailResponse> validEmail(@Valid @RequestBody MailValidRequest request) { | ||
boolean auth = emailTestService.validEmail(request.toService()); | ||
return ResponseEntity.ok(new ValidEmailResponse(auth)); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/kr/co/studyhubinu/studyhubserver/emailTest/EmailTestEntity.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,29 @@ | ||
package kr.co.studyhubinu.studyhubserver.emailTest; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Table(name = "email") | ||
public class EmailTestEntity { | ||
|
||
@Id | ||
@Column(name = "email_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
private String email; | ||
private String code; | ||
|
||
@Builder | ||
public EmailTestEntity(Long id, String email, String code) { | ||
this.id = id; | ||
this.email = email; | ||
this.code = code; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/kr/co/studyhubinu/studyhubserver/emailTest/EmailTestRepository.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,7 @@ | ||
package kr.co.studyhubinu.studyhubserver.emailTest; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface EmailTestRepository extends JpaRepository<EmailTestEntity, Long> { | ||
String findByEmail(String email); | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/kr/co/studyhubinu/studyhubserver/emailTest/EmailTestService.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,23 @@ | ||
package kr.co.studyhubinu.studyhubserver.emailTest; | ||
|
||
import kr.co.studyhubinu.studyhubserver.common.timer.Timer; | ||
import kr.co.studyhubinu.studyhubserver.email.dto.data.ValidMailInfo; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class EmailTestService { | ||
|
||
private final EmailTestRepository emailTestRepository; | ||
|
||
@Timer | ||
public boolean validEmail(ValidMailInfo info) { | ||
String authCode = emailTestRepository.findByEmail(info.getEmail()); | ||
log.info("**************************저장된 인증 코드" + authCode); | ||
log.info("**************************입력된 인증 코드" + info.getAuthCode()); | ||
return authCode != null && authCode.equals(info.getAuthCode()); | ||
} | ||
} |
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