最佳答案
我使用可选工具进行用户和邀请验证
@DeleteMapping("/friends/{username}")
public
HttpEntity<Boolean> removeFriend(
@ApiParam(value = "The user's name", required = true) @PathVariable String username
) {
Long fromId = authorizationService.getUserId();
return userService.findByUsername(username)
.map(user -> {
return friendshipService.findFriendship(fromId, user.getId())
.map(friendship -> {
friendshipService.removeFriendship(friendship);
friendship.setToId(friendship.getFromId());
friendship.setFromId(friendship.getToId());
friendshipService.removeFriendship(friendship);
return ResponseEntity.ok(true);
}).orElseGet(() -> ResponseEntity.notFound().build());
}).orElseThrow(() -> new ResourceNotFoundException("User not found"));
然而,IntelliJ
的颜色是我的灰色 return
,但当我删除的 return
,它突出了我,有没有 return
。
有人能解释一下它是怎么运作的吗?