@Override public User deleteUser(Long userId) { User userToDelete = getUser(userId); if (userToDelete != null) { userRepository.delete(userToDelete); } else { throw new UserNotFoundException(); } // return userDAO.deleteUser(userId); return userToDelete; }
@Override public List<User> getUsers() { // return userDAO.getUsers(); return userRepository.findAll(); }
@Override public User getUser(Long userId) { // return userDAO.getUser(userId); return userRepository.findOne(userId); }
@Override public User getUser(String username) { // return userDAO.getUser(username); return userRepository.findByUserName(username); }
@Override public User addUser(User user) { // return userDAO.addUser(user); user.setPassword(passwordEncoder.encode(user.getPassword())); return userRepository.save(user); }