UserRestController.java 文件源码

java
阅读 45 收藏 0 点赞 0 评论 0

项目:meditor 作者:
@PatchMapping("/{id}")
public ResponseEntity patchUser(@PathVariable Long id, @RequestBody JsonPatch jsonPatch) {
  return this.userService
      .getUserByID(id)
      .map(existing -> {
        try {
          JsonNode patched = jsonPatch.apply(objectMapper.convertValue(existing, JsonNode.class));

          UserDTO patchedUser = objectMapper.treeToValue(patched, UserDTO.class);
          // TODO add patched operations
          return ResponseEntity.ok(this.userService.update(patchedUser));
        } catch (JsonPatchException | JsonProcessingException e) {
          return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
        }
      })
      .orElse(ResponseEntity.notFound().build());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号