Exemplo n.º 1
0
  @RequestMapping(value = "/posts/{postId}/comments", method = RequestMethod.POST)
  public @ResponseBody Comment addComment(
      @PathVariable("postId") String postId, @RequestBody String commentText) {
    Comment comment = new Comment(null, commentText, 0, 0);

    return postRepository.saveCommentForPost(postId, comment);
  }
Exemplo n.º 2
0
 @RequestMapping(
     value = "/posts/{postId}/comments/{commentId}/dislike",
     method = RequestMethod.POST)
 public void dislikeComment(
     @PathVariable("postId") String postId, @PathVariable("commentId") String commentId) {
   postRepository.dislikeComment(postId, commentId);
 }
Exemplo n.º 3
0
  @RequestMapping(value = "/posts", method = GET, headers = "accept=application/json")
  public @ResponseBody List<Post> getExistingPosts() {

    return postRepository.getPostsWithoutComments();
  }
Exemplo n.º 4
0
 @RequestMapping(value = "/posts/{postId}/comments", method = GET)
 public @ResponseBody List<Comment> getCommentsForPost(@PathVariable String postId) {
   return postRepository.getPost(postId).getCommentsList();
 }
Exemplo n.º 5
0
 @RequestMapping(value = "/posts", method = RequestMethod.POST)
 public String addPost(@RequestBody Post post) {
   postRepository.savePost(post);
   return INDEX_PAGE;
 }