/**
* Function to delete a user -
* Only the administrators can perform this operation
*
* @param id
* @return ResponseEntity<DtoUser>
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public ResponseEntity<DtoUser> deleteOne(@PathVariable("id") final long id) {
if (!this.getLoggedInUser().isAdmin()) {
LOGGER.error(() -> "Users can only be deleted by system administrators");
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
}
final IUser found = serviceUser.findOne(id);
if (found == null) {
LOGGER.warn(() -> "User with id " + id + " not found");
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
LOGGER.debug(() -> "Deleting User with id " + id);
serviceUser.deleteUser(found.getId());
return new ResponseEntity<>(getDtoUser(found), HttpStatus.OK);
}
RestControllerAdminUser.java 文件源码
java
阅读 41
收藏 0
点赞 0
评论 0
项目:sporticus
作者:
评论列表
文章目录