Add serverside methods
This commit is contained in:
@@ -195,5 +195,14 @@ public class UserController {
|
||||
public Map<String, String> getResults(@RequestParam(value = "name") String name) {
|
||||
return userService.getResults(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method deletes a user from the database.
|
||||
* @param name name of the user
|
||||
*/
|
||||
@RequestMapping("/deleteAccount")
|
||||
public void removeFriend(@RequestParam(value = "name") String name) {
|
||||
userService.deleteAccount(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -303,4 +303,16 @@ public class UserService {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets the list of all users.
|
||||
* @return list of all users
|
||||
*/
|
||||
public void deleteAccount(String name) {
|
||||
User user = userRepository.findByName(name);
|
||||
if(user == null){
|
||||
throw new ApplicationException("User doesn't exist");
|
||||
}
|
||||
userRepository.delete(user);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user