GET userPost

Controller

@GetMapping(value = "/{id}/posts")
public ResponseEntity<List<PostDTO>> getUserPosts(@PathVariable String id) {
    List<PostDTO> obj = userService.getUsersPosts(id);
    return ResponseEntity.ok().body(obj);
}

Service

public List<PostDTO> getUsersPosts(String id) {
    User user = getEntityById(id);
    return user.getPosts().stream()
            .map(PostDTO::new).toList();
}

Atualizado