Class RecipeController

java.lang.Object
ntnu.idatt2016.v233.SmartMat.controller.product.RecipeController

@RestController @RequestMapping("/api/recipe") public class RecipeController extends Object
This class is responsible for handling requests related to recipes
Version:
1.0
Author:
Stian Lyng
  • Constructor Details

    • RecipeController

      public RecipeController()
  • Method Details

    • getRecipeById

      @GetMapping("/id/{id}") public org.springframework.http.ResponseEntity<Recipe> getRecipeById(@PathVariable("id") Long id)
      Gets a recipe by its id
      Parameters:
      id - the id of the recipe
      Returns:
      the recipe if it exists, otherwise 404
    • getRecipeByName

      @GetMapping("/name/{name}") public org.springframework.http.ResponseEntity<List<Recipe>> getRecipeByName(@PathVariable("name") String name)
      Gets all recipes with a given name
      Parameters:
      name - the name of the recipe
      Returns:
      a list of recipes with the given name, otherwise 404
    • addRecipeToFavorites

      @PostMapping("/favorite/{recipeId}") public org.springframework.http.ResponseEntity<String> addRecipeToFavorites(@PathVariable("recipeId") Long recipeId, org.springframework.security.core.Authentication authentication)
      add recipe to favorites in user
      Parameters:
      recipeId - the id of the recipe
      authentication - the authentication object
      Returns:
      200 if the recipe was added to favorites, otherwise 404
    • removeRecipeFromFavorites

      @DeleteMapping("/favorite/{recipeId}") public org.springframework.http.ResponseEntity<String> removeRecipeFromFavorites(@PathVariable("recipeId") Long recipeId, org.springframework.security.core.Authentication authentication)
      remove recipe from favorites in user
      Parameters:
      recipeId - the id of the recipe
      authentication - the authentication object
      Returns:
      200 if the recipe was removed from favorites, otherwise 404