Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import java.util.Optional;

public interface UserRepository extends JpaRepository<User, Long> {
boolean existsByEmail(String email);
boolean existsByUsername(String username);
Optional<User> findByEmail(String email);
Optional<User> findByUsername(String username);

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ public class UserService {
public UserResponseDto signup(RequestDto dto){

// 이메일 중복 확인
if(userRepository.existsByEmail(dto.getEmail())){
throw new CustomException(ErrorCode.DUPLICATE_EMAIL);
}

userRepository.findByEmail(dto.getEmail()).ifPresent(
user -> {throw new CustomException(ErrorCode.DUPLICATE_EMAIL);}
);

// 아이디 중복 확인
if(userRepository.existsByUsername(dto.getUsername())){
throw new CustomException(ErrorCode.DUPLICATE_USER);
}
userRepository.findByUsername(dto.getUsername()).ifPresent(
user -> {throw new CustomException(ErrorCode.DUPLICATE_USER);}
);

// Dto → Entity
User user = UserMapper.user(dto);
Expand Down