@RequestMapping(value="/posts/{id:\\d+}/vote",method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<PostVoteDTO> vote(@PathVariable Long id,@RequestParam(required=true) String type){
  log.debug("REST request to vote-up Post : {}",id);
  Post post=postRepository.findByStatusAndId(PostStatus.PUBLIC,id);
  if (post == null || !(type.equals("up") || type.equals("down"))) {
    return new ResponseEntity<>(new PostVoteDTO(),HttpStatus.UNPROCESSABLE_ENTITY);
  }
  String result;
  if (type.equals("up")) {
    result=voteService.voteUp(post,userService.getUserWithAuthorities());
  }
 else {
    result=voteService.voteDown(post,userService.getUserWithAuthorities());
  }
  return new ResponseEntity<>(new PostVoteDTO(post,result),HttpStatus.OK);
}

@ RequestMapping ( value = "/posts/{id:\\d+}/vote" , method = RequestMethod . POST , produces = MediaType . APPLICATION_JSON_VALUE ) @ Timed public ResponseEntity < PostVoteDTO > vote ( @ PathVariable Long id , @ RequestParam ( required = true ) String type ) { log . debug ( "REST request to vote-up Post : {}" , id ) ; Post post = postRepository . findByStatusAndId ( PostStatus . PUBLIC , id ) ; if ( post == null || ! ( type . equals ( "up" ) || type . equals ( "down" ) ) ) { return new ResponseEntity < > ( new PostVoteDTO ( ) , HttpStatus . UNPROCESSABLE_ENTITY ) ; } String result ; if ( type . equals ( "up" ) ) { result = voteService . voteUp ( post , userService . getUserWithAuthorities ( ) ) ; } else { result = voteService . voteDown ( post , userService . getUserWithAuthorities ( ) ) ; } return new ResponseEntity < > ( new PostVoteDTO ( post , result ) , HttpStatus . OK ) ; }
post / posts / : id - > get the " id " post .
