-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: UserSignUpPolicy Domain Service 구현 및 SignUp 로직에 반영
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
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/com/gloddy/server/auth/domain/service/UserSignUpPolicy.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 com.gloddy.server.auth.domain.service; | ||
|
||
import com.gloddy.server.auth.domain.User; | ||
import com.gloddy.server.auth.domain.vo.Phone; | ||
import com.gloddy.server.auth.exception.AlreadyUserSignUpException; | ||
import com.gloddy.server.user.infra.repository.UserJpaRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Optional; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class UserSignUpPolicy { | ||
|
||
private final UserJpaRepository userJpaRepository; | ||
|
||
public void validate(String phoneNumber) { | ||
Phone phone = new Phone(phoneNumber); | ||
|
||
Optional<User> user = userJpaRepository.findByPhone(phone); | ||
|
||
if (user.isPresent()) { | ||
throw new AlreadyUserSignUpException(); | ||
} | ||
} | ||
} |