Added edit Cache

This commit is contained in:
Maximilian Leopold 2019-05-10 17:50:45 +02:00
parent ec4202a5aa
commit c5ffa61eda

View File

@ -324,6 +324,32 @@ public class Controller {
return createCacheUtil(cache);
}
@RequestMapping(value = "/api/editCache", method = RequestMethod.PUT, produces = "application/json")
@ResponseBody
public ResponseEntity editCache(@RequestBody Cache newCache){
//----------------------
//Get Cache
ResponseEntity getCache = FinderUtil.findCacheById(newCache.getId() + "");
if (getCache.getStatusCodeValue() != 200) {
return getCache;
}
Cache oldCache = (Cache) getCache.getBody();
//----------------------
oldCache.setDescription(newCache.getDescription());
oldCache.setName(newCache.getName());
oldCache.setRankingPoints(newCache.getRankingPoints());
oldCache.setReward(newCache.getReward());
oldCache.setStationen(newCache.getStationen());
cacheRepository.save(oldCache);
return ResponseEntity.status(200).body("Cache edited");
}
@ApiOperation(value = "Checks if the given User has an admin role")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"),