示例#1
0
  @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;
  }
示例#2
0
 @Override
 public List<User> getUsers() {
   // return userDAO.getUsers();
   return userRepository.findAll();
 }
示例#3
0
 @Override
 public User getUser(Long userId) {
   // return userDAO.getUser(userId);
   return userRepository.findOne(userId);
 }
示例#4
0
 @Override
 public User getUser(String username) {
   // return userDAO.getUser(username);
   return userRepository.findByUserName(username);
 }
示例#5
0
 @Override
 public User addUser(User user) {
   // return userDAO.addUser(user);
   user.setPassword(passwordEncoder.encode(user.getPassword()));
   return userRepository.save(user);
 }