[Spring] Implementing DELETE Method to delete a User Resource
Building REST API with Spring Boot (6)
/ !!!!!! /
Implementing DELETE Method to delete a User Resource
UserResource.java
// Delete /users
@DeleteMapping("/users/{id}")
public void deleteUser(@PathVariable int id) {
service.deleteById(id);
}
UserDaoService.java
public void deleteById(int id) {
Predicate<? super User> predicate = user -> user.getId().equals(id);
users.removeIf(predicate);
}
댓글남기기