Skip to content
Snippets Groups Projects
Commit 70762c94 authored by Stian Lyng's avatar Stian Lyng
Browse files

get fridge by id

parent d3834d0b
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,19 @@ public class FridgeController {
.orElseGet(() -> ResponseEntity.notFound().build());
}
/**
* Gets the fridge by its fridge id
* @param fridgeId the id of the fridge
* @return the fridge if it exists, or a 404 if it doesn't
*/
@GetMapping("/fridge/{fridgeId}")
public ResponseEntity<Fridge> getFridgeByFridgeId(@PathVariable("fridgeId") long fridgeId) {
return fridgeService.getFridgeByFridgeId(fridgeId)
.map(ResponseEntity::ok)
.orElseGet(() -> ResponseEntity.notFound().build());
}
/**
* Adds a product to the fridge of a group
*
......
......@@ -37,6 +37,17 @@ public class FridgeService {
public Optional<Fridge> getFridgeByGroupId(long groupId) {
return fridgeRepository.findByGroupId(groupId);
}
/**
* Gets the fridge by its fridge id
*
* @param fridgeId the id of the fridge
* @return the fridge if it exists
*/
public Optional<Fridge> getFridgeByFridgeId(long fridgeId) {
return fridgeRepository.findById(fridgeId);
}
/**
* Add a product to the fridge of a group
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment