diff --git a/.idea/modules.xml b/.idea/modules.xml index 9db8a1d..50b8b01 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -5,6 +5,7 @@ + \ No newline at end of file diff --git a/build.gradle b/build.gradle index e8e2fc4..0f33646 100644 --- a/build.gradle +++ b/build.gradle @@ -30,6 +30,9 @@ dependencies { //Thymeleaf compile("org.springframework.boot:spring-boot-starter-thymeleaf") + + //JSON Parser + implementation 'com.google.code.gson:gson:2.8.5' } node { diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index 88fb708..9a8501d 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -1,9 +1,13 @@ package hhn.labsw.bugageocaching.controller; +import com.google.gson.Gson; +import hhn.labsw.bugageocaching.entities.Cache; import hhn.labsw.bugageocaching.repositories.CacheRepository; import hhn.labsw.bugageocaching.repositories.RewardRepository; import hhn.labsw.bugageocaching.repositories.StationRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; @RestController @@ -18,4 +22,10 @@ public class Controller { @Autowired StationRepository stationRepository; + @RequestMapping("/allCaches") + @ResponseBody + public String getAllCaches(){ + return new Gson().toJson(cacheRepository.findAll()); + } + }