refactored code
This commit is contained in:
parent
38097dad8e
commit
baab96059b
@ -97,7 +97,7 @@ public class Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Optional<CacheAccesDefinition> cacheAccesDefinitionOptional =
|
Optional<CacheAccesDefinition> cacheAccesDefinitionOptional =
|
||||||
cacheAccesDefinitionRepository.findById(0); // bearbeitet
|
cacheAccesDefinitionRepository.findById(0); // bearbeitet
|
||||||
if (cacheAccesDefinitionOptional.isPresent()) {
|
if (cacheAccesDefinitionOptional.isPresent()) {
|
||||||
CacheAccesDefinition cacheAccesDefinition = cacheAccesDefinitionOptional.get();
|
CacheAccesDefinition cacheAccesDefinition = cacheAccesDefinitionOptional.get();
|
||||||
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
|
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
|
||||||
@ -135,9 +135,9 @@ public class Controller {
|
|||||||
@RequestMapping("/api/createStation")
|
@RequestMapping("/api/createStation")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
String createStation(@RequestParam String description,
|
String createStation(@RequestParam String description,
|
||||||
@RequestParam String lattitude,
|
@RequestParam String lattitude,
|
||||||
@RequestParam String longitude,
|
@RequestParam String longitude,
|
||||||
@RequestParam String solution) throws IllegalParameterException {
|
@RequestParam String solution) throws IllegalParameterException {
|
||||||
|
|
||||||
if (description.length() == 0 || lattitude.length() == 0 || longitude.length() == 0 || solution.length() == 0) {
|
if (description.length() == 0 || lattitude.length() == 0 || longitude.length() == 0 || solution.length() == 0) {
|
||||||
throw new IllegalParameterException("Fields can´t be empty");
|
throw new IllegalParameterException("Fields can´t be empty");
|
||||||
@ -205,10 +205,10 @@ public class Controller {
|
|||||||
@RequestMapping("/api/createCache")
|
@RequestMapping("/api/createCache")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
String createCache(@RequestParam String description,
|
String createCache(@RequestParam String description,
|
||||||
@RequestParam String name,
|
@RequestParam String name,
|
||||||
@RequestParam String rankingPoints,
|
@RequestParam String rankingPoints,
|
||||||
@RequestParam(value = "rewardID", defaultValue = "-1") String rewardID,
|
@RequestParam(value = "rewardID", defaultValue = "-1") String rewardID,
|
||||||
@RequestParam List<Station> stationen) throws IllegalParameterException {
|
@RequestParam List<Station> stationen) throws IllegalParameterException {
|
||||||
|
|
||||||
if (description.length() == 0 || name.length() == 0 || rankingPoints.length() == 0 || stationen.size() == 0) {
|
if (description.length() == 0 || name.length() == 0 || rankingPoints.length() == 0 || stationen.size() == 0) {
|
||||||
throw new IllegalParameterException("Fields can´t be empty");
|
throw new IllegalParameterException("Fields can´t be empty");
|
||||||
@ -244,11 +244,11 @@ public class Controller {
|
|||||||
|
|
||||||
cacheRepository.save(cache);
|
cacheRepository.save(cache);
|
||||||
|
|
||||||
for(int i = 0; i + 1 < stationen.size(); i++) {
|
for (int i = 0; i + 1 < stationen.size(); i++) {
|
||||||
StationReihenfolge stationReihenfolge = new StationReihenfolge();
|
StationReihenfolge stationReihenfolge = new StationReihenfolge();
|
||||||
stationReihenfolge.setCache(cache);
|
stationReihenfolge.setCache(cache);
|
||||||
stationReihenfolge.setStation(stationen.get(i));
|
stationReihenfolge.setStation(stationen.get(i));
|
||||||
stationReihenfolge.setNachfolgeStation(stationen.get(i+1));
|
stationReihenfolge.setNachfolgeStation(stationen.get(i + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Gson().toJson(cache);
|
return new Gson().toJson(cache);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user