Added GSON to gradle | /allCaches now returns a JSON with All Caches in DB

This commit is contained in:
Maximilian Leopold 2019-03-22 18:26:18 +01:00
parent c6a9b77a0a
commit af2c4e49ea
3 changed files with 14 additions and 0 deletions

1
.idea/modules.xml generated
View File

@ -5,6 +5,7 @@
<module fileurl="file://$PROJECT_DIR$/.idea/modules/de.hhn.labsw.labswp_2019_sose_geocaching.iml" filepath="$PROJECT_DIR$/.idea/modules/de.hhn.labsw.labswp_2019_sose_geocaching.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/de.hhn.labsw.labswp_2019_sose_geocaching.main.iml" filepath="$PROJECT_DIR$/.idea/modules/de.hhn.labsw.labswp_2019_sose_geocaching.main.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/de.hhn.labsw.labswp_2019_sose_geocaching.test.iml" filepath="$PROJECT_DIR$/.idea/modules/de.hhn.labsw.labswp_2019_sose_geocaching.test.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/labswp_2019_sose_geocaching.iml" filepath="$PROJECT_DIR$/.idea/labswp_2019_sose_geocaching.iml" />
</modules>
</component>
</project>

View File

@ -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 {

View File

@ -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());
}
}