-
Notifications
You must be signed in to change notification settings - Fork 0
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
[FEAT] 번호 인증 검사 기능 구현 #15
Open
yummygyudon
wants to merge
14
commits into
dev
Choose a base branch
from
feat/#10
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d8b0159
[FEAT] 번호 인증 검사 API Response Body 데이터 정의
yummygyudon a4c06ce
[FEAT] 번호 인증 Usecase 및 Command 정의
yummygyudon 270684e
[FEAT] 번호 인증 데이터 Out Port 정의 및 JPA 메서드 선언
yummygyudon e57a769
[FEAT] 번호 인증 검사 In Port Usecase 구현
yummygyudon 72cf821
[FEAT] 번호 인증 요청에 대한 API 메서드 구현
yummygyudon 0ab5f54
[TEST] PhoneVerification 객체 간 동일여부 판단 메서드 테스트
yummygyudon 9d0c2f2
[FIX] PhoneVerification Inner Record `@EqualsAndHashCode` 추가
yummygyudon 557048a
[REFACTOR] Transaction Helper 객체 구현
yummygyudon 87b7deb
[REFACTOR] PhoneVerification Out Port 메서드명 개선
yummygyudon b134dda
[CHORE] 소스코드 변경 사항 및 패키징 추가 반영
yummygyudon 83c80bf
[CHORE] 와일드 카드 제거 및 Usecase 반환 데이터 변경 반영
yummygyudon f52d94e
[FIX] 요구사항에 따른 PhoneVerification Null 가능 반영
yummygyudon 78bf06e
[TEST] PhoneVerification Null 가능 반영 정상 작동 여부 확인
yummygyudon a23cbf4
[REFACTOR] 트랜젝션 처리/예외 처리 계층 변경
yummygyudon 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 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
38 changes: 38 additions & 0 deletions
38
src/main/java/sopt/makers/authentication/database/PhoneVerificationRepositoryImpl.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,38 @@ | ||
package sopt.makers.authentication.database; | ||
yummygyudon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import sopt.makers.authentication.database.rdb.entity.auth.PhoneVerificationEntity; | ||
import sopt.makers.authentication.database.rdb.repository.auth.PhoneVerificationRegister; | ||
import sopt.makers.authentication.database.rdb.repository.auth.PhoneVerificationRemover; | ||
import sopt.makers.authentication.database.rdb.repository.auth.PhoneVerificationRetriever; | ||
import sopt.makers.authentication.domain.auth.PhoneVerification; | ||
import sopt.makers.authentication.usecase.auth.port.out.PhoneVerificationRepository; | ||
|
||
import org.springframework.stereotype.Repository; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class PhoneVerificationRepositoryImpl implements PhoneVerificationRepository { | ||
|
||
private final PhoneVerificationRegister register; | ||
private final PhoneVerificationRetriever retriever; | ||
private final PhoneVerificationRemover remover; | ||
yummygyudon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@Override | ||
public PhoneVerification create(PhoneVerification phoneVerification) { | ||
PhoneVerificationEntity createdEntity = register.register(phoneVerification); | ||
return createdEntity.toDomain(); | ||
} | ||
|
||
@Override | ||
public PhoneVerification findByPhoneVerification(PhoneVerification phoneVerification) { | ||
PhoneVerificationEntity phoneVerificationEntity = retriever.find(phoneVerification); | ||
return phoneVerificationEntity.toDomain(); | ||
} | ||
|
||
@Override | ||
public void deletedByPhoneVerification(PhoneVerification phoneVerification) { | ||
remover.remove(phoneVerification); | ||
} | ||
} |
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
7 changes: 0 additions & 7 deletions
7
...va/sopt/makers/authentication/database/rdb/repository/PhoneVerificationJpaRepository.java
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
...a/sopt/makers/authentication/database/rdb/repository/PhoneVerificationRepositoryImpl.java
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
...pt/makers/authentication/database/rdb/repository/auth/PhoneVerificationJpaRepository.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,17 @@ | ||
package sopt.makers.authentication.database.rdb.repository.auth; | ||
|
||
import sopt.makers.authentication.database.rdb.entity.auth.PhoneVerificationEntity; | ||
import sopt.makers.authentication.domain.auth.PhoneVerificationType; | ||
|
||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
interface PhoneVerificationJpaRepository extends JpaRepository<PhoneVerificationEntity, Long> { | ||
|
||
Optional<PhoneVerificationEntity> findByPhoneAndCodeAndType( | ||
String phone, String code, PhoneVerificationType type); | ||
|
||
void deleteByNameAndPhoneAndCodeAndType( | ||
String name, String phone, String code, PhoneVerificationType type); | ||
} |
28 changes: 28 additions & 0 deletions
28
...va/sopt/makers/authentication/database/rdb/repository/auth/PhoneVerificationRegister.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,28 @@ | ||
package sopt.makers.authentication.database.rdb.repository.auth; | ||
|
||
import sopt.makers.authentication.database.rdb.entity.auth.PhoneVerificationEntity; | ||
import sopt.makers.authentication.domain.auth.PhoneVerification; | ||
|
||
import jakarta.transaction.Transactional; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Component | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class PhoneVerificationRegister { | ||
|
||
private final PhoneVerificationJpaRepository jpaRepository; | ||
|
||
public PhoneVerificationEntity register(PhoneVerification phoneVerification) { | ||
PhoneVerificationEntity entity = PhoneVerificationEntity.fromDomain(phoneVerification); | ||
return jpaRepository.save(entity); | ||
} | ||
|
||
public PhoneVerificationEntity register(final long id, PhoneVerification phoneVerification) { | ||
PhoneVerificationEntity entity = PhoneVerificationEntity.fromDomain(id, phoneVerification); | ||
return jpaRepository.save(entity); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ava/sopt/makers/authentication/database/rdb/repository/auth/PhoneVerificationRemover.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,25 @@ | ||
package sopt.makers.authentication.database.rdb.repository.auth; | ||
|
||
import sopt.makers.authentication.domain.auth.PhoneVerification; | ||
|
||
import jakarta.transaction.Transactional; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Component | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class PhoneVerificationRemover { | ||
|
||
private final PhoneVerificationJpaRepository jpaRepository; | ||
|
||
public void remove(PhoneVerification phoneVerification) { | ||
jpaRepository.deleteByNameAndPhoneAndCodeAndType( | ||
phoneVerification.getName(), | ||
phoneVerification.getPhone(), | ||
phoneVerification.getVerificationCode().getCode(), | ||
phoneVerification.getVerificationType()); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...a/sopt/makers/authentication/database/rdb/repository/auth/PhoneVerificationRetriever.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,28 @@ | ||
package sopt.makers.authentication.database.rdb.repository.auth; | ||
|
||
import sopt.makers.authentication.database.rdb.entity.auth.PhoneVerificationEntity; | ||
import sopt.makers.authentication.domain.auth.PhoneVerification; | ||
import sopt.makers.authentication.support.code.domain.failure.AuthFailure; | ||
import sopt.makers.authentication.support.exception.domain.AuthException; | ||
|
||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Component | ||
@Transactional(readOnly = true) | ||
@RequiredArgsConstructor | ||
public class PhoneVerificationRetriever { | ||
|
||
private final PhoneVerificationJpaRepository jpaRepository; | ||
|
||
public PhoneVerificationEntity find(PhoneVerification phoneVerification) { | ||
return jpaRepository | ||
.findByPhoneAndCodeAndType( | ||
phoneVerification.getPhone(), | ||
phoneVerification.getVerificationCode().getCode(), | ||
phoneVerification.getVerificationType()) | ||
.orElseThrow(() -> new AuthException(AuthFailure.NOT_FOUND_PHONE_VERIFICATION)); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
.../java/sopt/makers/authentication/usecase/auth/port/in/VerifyPhoneVerificationUsecase.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,11 @@ | ||
package sopt.makers.authentication.usecase.auth.port.in; | ||
|
||
import sopt.makers.authentication.domain.auth.PhoneVerificationType; | ||
|
||
public interface VerifyPhoneVerificationUsecase { | ||
|
||
boolean verify(VerifyVerificationCommand command); | ||
|
||
record VerifyVerificationCommand( | ||
String name, String phone, String code, PhoneVerificationType verificationType) {} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
src/main/java/sopt/makers/authentication/usecase/auth/service/VerifyVerificationService.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,30 @@ | ||
package sopt.makers.authentication.usecase.auth.service; | ||
|
||
import sopt.makers.authentication.domain.auth.PhoneVerification; | ||
import sopt.makers.authentication.usecase.auth.port.in.VerifyPhoneVerificationUsecase; | ||
import sopt.makers.authentication.usecase.auth.port.out.PhoneVerificationRepository; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class VerifyVerificationService implements VerifyPhoneVerificationUsecase { | ||
private final PhoneVerificationRepository phoneVerificationRepository; | ||
|
||
@Override | ||
public boolean verify(VerifyVerificationCommand command) { | ||
PhoneVerification targetVerification = | ||
PhoneVerification.of( | ||
command.name(), command.phone(), command.verificationType(), command.code()); | ||
PhoneVerification findVerification = | ||
phoneVerificationRepository.findByPhoneVerification(targetVerification); | ||
boolean isVerified = targetVerification.equals(findVerification); | ||
|
||
if (isVerified) { | ||
phoneVerificationRepository.deletedByPhoneVerification(findVerification); | ||
yummygyudon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
return isVerified; | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p3
회원가입에서 번호 인증을 사용하게 되면 운영진이 제공해준 사용자 정보를 식별할 수 있는 값도 전달되어야 할 것 같은데 어떻게 생각하시나요? 컨트롤러를 분리하는게 좋을지 response에서 필드를 추가해 재사용하는게 좋을지 고민되어 일단 response에 남겨봅니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오호옷!!
식별 데이터라 하심은
임원진으로부터 전달받은 "신규회원 csv를 저장한 테이블"에서의 ID를 넘겨주자는 거죠?!
전 좋은 것 같습니다!!
그래야만 소셜 인증 요청 시, 인증된 csv 내 신규회원 식별 값을 함께 넘겨 해당 DB에서 삭제까지 용이하게 할 수 있겠군요
(저희가 논의했을 땐, 소셜인증까지 완료했을 때만 csv 저장 데이터를 삭제하자고 했었으니까!!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 근데 고려되어야 할 점이 회원가입 시점에서는 csv 파일을 저장한 id를 넘겨주셔야하지만 소셜계정 변경을 위해 번호인증을 한 경우에는 실제 유저의 id를 넘겨주시거나 다른 값(현재 사용되고 있는 socialPlaltformId 등)을 전달 해야할 것 같은데 어떻게 생각하시나요?