userRepository .findByUserId(req.getUserId()) .ifPresent( user -> { thrownew UniqueException("already user"); });
final String id = req.getUserType() + UUID.randomUUID().toString(); UserCollection userCollection = UserCollection.builder() .id(id) .userId(req.getUserId()) .userName(req.getUserName()) .email(req.getEmail()) .address(req.getAddress()) .age(req.getAge()) .build();
userRepository.save(userCollection); }
public UserDto getUserData(String userId){
UserCollection userCollection = userRepository .findByUserId(userId) .orElseThrow(() -> new NotFoundException("user data is not found"));
return UserDto.toUserDto(userCollection); }
@Transactional publicvoiddeleteUser(String userId){ UserCollection userCollection = userRepository .findByUserId(userId) .orElseThrow(() -> new NotFoundException("user data is not found"));