Skip to content

Commit

Permalink
Merge branch 'Twitter-Clone-Group:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
nickchoi10 authored Sep 4, 2022
2 parents fbb2f1f + 58a790b commit 1cb6df5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,13 @@ public ResponseEntity<Squeaker> save(@RequestBody Squeaker squeaker) {
public ResponseEntity<Squeaker> update(@PathVariable Long id, @RequestBody Squeaker squeaker) {
return new ResponseEntity<>(squeakerService.updateSqueaker(id, squeaker), HttpStatus.OK);
}

@DeleteMapping("/{username}")
private ResponseEntity<Object> deleteSqueaker(@PathVariable("username") String username, @PathVariable("password") String password) {
try {
return new ResponseEntity<>(squeakerService.deleteSqueaker(username, password), HttpStatus.NO_CONTENT);
} catch (IllegalArgumentException exception) {
return new ResponseEntity<>(exception.getMessage(), HttpStatus.NOT_FOUND);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,10 @@ public Squeaker updateSqueaker (Long id, Squeaker squeaker) {

return oldSqueaker;
}

public Boolean deleteSqueaker(String username, String password) {
Squeaker squeakerToDelete = findSqueakerByUsername(username, password);
squeakerRepository.delete(squeakerToDelete);
return Boolean.TRUE;
}
}

0 comments on commit 1cb6df5

Please sign in to comment.