Class ShoppingListController
java.lang.Object
ntnu.idatt2016.v233.SmartMat.controller.group.ShoppingListController
@RestController
@RequestMapping("/api/shoppinglist")
public class ShoppingListController
extends Object
Controller for the shopping list
- Version:
- 1.0
- Author:
- Stian Lyng
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<?>
addItemToShoppingList
(long shoppingListId, String ean, org.springframework.security.core.Authentication auth) Adds a product to a shopping listorg.springframework.http.ResponseEntity<ShoppingList>
getAllShoppingListsByGroupId
(long id, org.springframework.security.core.Authentication auth) Gets a shopping list by its group IDorg.springframework.http.ResponseEntity<ShoppingList>
getShoppingListById
(long id, org.springframework.security.core.Authentication auth) Gets a shopping list by its IDorg.springframework.http.ResponseEntity<ShoppingList>
removeProductFromShoppingList
(String shoppingListId, String ean, org.springframework.security.core.Authentication auth) Removes a product from a shopping list
-
Constructor Details
-
ShoppingListController
public ShoppingListController()
-
-
Method Details
-
getShoppingListById
@GetMapping("/{id}") public org.springframework.http.ResponseEntity<ShoppingList> getShoppingListById(@PathVariable("id") long id, org.springframework.security.core.Authentication auth) Gets a shopping list by its ID- Parameters:
id
- the shopping list IDauthentication
- The authentication object of the user.- Returns:
- the shopping list, or an error if the ID is invalid, or the user dose not have the rights to edit the shopping list
-
getAllShoppingListsByGroupId
@GetMapping("/group/{groupId}") public org.springframework.http.ResponseEntity<ShoppingList> getAllShoppingListsByGroupId(@PathVariable("groupId") long id, org.springframework.security.core.Authentication auth) Gets a shopping list by its group ID- Parameters:
id
- the request containing the group IDauthentication
- The authentication object of the user.- Returns:
- the shopping list, or an error if the ID is invalid
-
addItemToShoppingList
@PostMapping("/addProduct/{shoppingListId}/{ean}") public org.springframework.http.ResponseEntity<?> addItemToShoppingList(@PathVariable("shoppingListId") long shoppingListId, @PathVariable("ean") String ean, org.springframework.security.core.Authentication auth) Adds a product to a shopping list- Parameters:
shoppingListId
- the shopping list IDean
- the product EANauth
- the authentication object- Returns:
- the shopping list with the added product, or an error if the shopping list ID or EAN is invalid
-
removeProductFromShoppingList
@DeleteMapping("/removeProduct/{shoppingListId}/{ean}") public org.springframework.http.ResponseEntity<ShoppingList> removeProductFromShoppingList(@PathVariable("shoppingListId") String shoppingListId, @PathVariable("ean") String ean, org.springframework.security.core.Authentication auth) Removes a product from a shopping list- Parameters:
shoppingListId
- the shopping list IDean
- the product EANauth
- The authentication object of the user.- Returns:
- the shopping list with the removed product, or an error if the shopping list ID or EAN is invalid
-