Skip to content

Commit

Permalink
Merge pull request #7 from TeamUStory/feat/user
Browse files Browse the repository at this point in the history
Feat/user
  • Loading branch information
GyungA authored Jul 2, 2024
2 parents e38da87 + 2fdc864 commit 6656ef8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ public interface UserRepository extends JpaRepository<Users, Long> {
boolean existsByEmail(String loginEmail);

@Query(value = "SELECT COUNT(*) FROM users u WHERE u.email = :email", nativeQuery = true)
int existsByEmailWithSoftDeleted(@Param("email") String email);
int countByEmailWithSoftDeleted(@Param("email") String email);

@Query(value = "SELECT COUNT(*) FROM users u WHERE u.nickname = :nickname", nativeQuery = true)
int countByNicknameWithSoftDeleted(@Param("nickname") String nickname);
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public EmailVerifyResponse validateEmail(String email) {
.build();
}

int emailCountWithSoftDeleted = userRepository.existsByEmailWithSoftDeleted(email);
int emailCountWithSoftDeleted = userRepository.countByEmailWithSoftDeleted(email);
if (emailCountWithSoftDeleted > 0) {
return EmailVerifyResponse.builder()
.isSuccess(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ public Users signUp(SignUpRequest signUpRequest) {

// 1-2. 이메일 중복 재확인
String email = signUpRequest.getEmail();
if (userRepository.findByEmail(email).isPresent()) {

int emailCountWithSoftDeleted = userRepository.countByEmailWithSoftDeleted(email);
if (emailCountWithSoftDeleted > 0) {
throw new ConflictException(String.format(UserMessageConstants.DUPLICATE_EMAIL_MESSAGE, email));
}

Expand Down Expand Up @@ -262,7 +264,8 @@ public MyPageResponse showMyPage(Long userId) {
public ValidateNicknameResponse isValidNickname(ValidateNicknameRequest validateNicknameRequest) {
String nickname = validateNicknameRequest.getNickname();

if (userRepository.findByNickname(nickname).isPresent()) {
int nicknameCountWithSoftDeleted = userRepository.countByNicknameWithSoftDeleted(nickname);
if (nicknameCountWithSoftDeleted > 0) {
return ValidateNicknameResponse.builder()
.isValid(false)
.isDuplicate(true)
Expand Down

0 comments on commit 6656ef8

Please sign in to comment.