package com.elderstudios.controller;

import com.elderstudios.domain.GuestBookEntry;
import com.elderstudios.service.GuestBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.persistence.criteria.CriteriaBuilder;
import java.util.List;

/**
 * Created by tony on 04/07/17.
 */

@RestController
public class GuestBookRestController {

    private static final String prefix = "api";

    @Autowired
    private GuestBookService guestBookService;

    @GetMapping (prefix + "/comments")
    public List <GuestBookEntry> apiAllComments () {
        return this.guestBookService.findAllEntries ();
    }

    @GetMapping (prefix + "/find/{id}")
    public List <GuestBookEntry> apiCommentById (@PathVariable ("id") Integer id) {
        return this.guestBookService.getGuestBookEntryById (id);
    }

    @GetMapping (prefix + "/users")
    public List <String> apiGetDistinctUsers () {
        return this.guestBookService.findDistinctUsers ();
    }

    @GetMapping (prefix + "/comment_count")
    public Integer getNumberOfComments () {
        return this.guestBookService.getNumberOfComments ();
    }

    @GetMapping (prefix + "/average_length")
    public Double getAverageCommentLength () {
        return this.guestBookService.getAverageCommentLength ();
    }

    @GetMapping (prefix + "/longest_comment")
    public List <String> getLongestComment () {
        return this.guestBookService.getLongestComment ();
    }
}

@@ -242,142 +242,9 @@
 ion.
-GetMapping;%0Aimport org.springframework.web.bind.annotation.PathVariable;%0Aimport org.springframework.web.bind.annotation.RestController
+*
 ;%0A%0Ai
@@ -374,16 +374,41 @@
 troller%0A
+@RequestMapping (%22/api%22)%0A
 public c
@@ -439,24 +439,26 @@
 ller %7B%0A%0A    
+//
 private stat
@@ -566,33 +566,24 @@
 GetMapping (
-prefix + 
 %22/comments%22)
@@ -716,25 +716,16 @@
 apping (
-prefix + 
 %22/find/%7B
@@ -903,25 +903,16 @@
 apping (
-prefix + 
 %22/users%22
@@ -1046,25 +1046,16 @@
 apping (
-prefix + 
 %22/commen
@@ -1193,25 +1193,16 @@
 apping (
-prefix + 
 %22/averag
@@ -1352,17 +1352,8 @@
 ng (
-prefix + 
 %22/lo
@@ -1475,16 +1475,17 @@
 ent ();%0A
-
     %7D%0A
+%0A
 %7D%0A

Refactor REST controller to use overall @RequestMapping