Class UCSBDiningCommonsMenuItemController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemController
@RequestMapping("/api/ucsbdiningcommonsmenuitem")
@RestController
public class UCSBDiningCommonsMenuItemController
extends ApiController
This is a REST controller for UCSBDiningCommonsMenuItem
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList all UCSB Dining Commons menu itemsdeleteById(Long id) Delete a single menu item by id, ex: /api/ucsbdiningcommonsmenuitem?Get a single record from the table by databse idpostUCSBDiningCommonsMenuItem(String diningCommonsCode, String name, String station) Create a new menu itemupdateUCSBDiningCommonsMenuItem(Long id, UCSBDiningCommonsMenuItem incoming) Update a single menu itemMethods inherited from class edu.ucsb.cs156.example.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
UCSBDiningCommonsMenuItemController
public UCSBDiningCommonsMenuItemController()
-
-
Method Details
-
allUCSBDiningCommonsMenuItems
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<UCSBDiningCommonsMenuItem> allUCSBDiningCommonsMenuItems()List all UCSB Dining Commons menu items- Returns:
- an iterable of UCSBDiningCommonsMenuItem
-
postUCSBDiningCommonsMenuItem
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public UCSBDiningCommonsMenuItem postUCSBDiningCommonsMenuItem(@RequestParam String diningCommonsCode, @RequestParam String name, @RequestParam String station) throws com.fasterxml.jackson.core.JsonProcessingException Create a new menu item- Parameters:
diningCommonsCode- the code of the dining commons (e.g. "ortega", "dlg")name- the name of the menu itemstation- the station where the item is served (e.g. "Entrees", "Desserts")- Returns:
- the saved menu item
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
deleteById
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteById(@RequestParam Long id) Delete a single menu item by id, ex: /api/ucsbdiningcommonsmenuitem?id=XXX- Parameters:
id- the id of the menu item- Returns:
- if exists "record XXX deleted" if DNE "record XXX not found"
-
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public UCSBDiningCommonsMenuItem getById(@RequestParam Long id) Get a single record from the table by databse id- Parameters:
id- of the menu item record- Returns:
- JSON of the database record with id XXX if exists, error message "id XXX not found" if DNE
-
updateUCSBDiningCommonsMenuItem
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public UCSBDiningCommonsMenuItem updateUCSBDiningCommonsMenuItem(@RequestParam Long id, @RequestBody UCSBDiningCommonsMenuItem incoming) Update a single menu item- Parameters:
id- database id of the menu item to updateincoming- the new menu item values- Returns:
- the updated menu item
-