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 UCSBDiningCommonsMenuItems
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionList all UCSB menu itemsDelete a menu itemGet a single menu item by idpostUCSBDiningCommonsMenuItem
(String diningCommonsCode, String name, String station) Create a new menuupdateUCSBMenuItem
(Long id, @Valid 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
-
allUCSBMenuItems
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<UCSBDiningCommonsMenuItem> allUCSBMenuItems()List all UCSB menu items- Returns:
- an iterable of UCSBDiningCommonsMenuItem
-
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public UCSBDiningCommonsMenuItem getById(@RequestParam Long id) Get a single menu item by id- Parameters:
id
- the id of the menu item- Returns:
- a UCSB menu item
-
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- Parameters:
diningCommonsCode
- code of the UCSB dining commonname
- name of the menu itemstation
- station of the menu item- Returns:
- the saved menu
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
updateUCSBMenuItem
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public UCSBDiningCommonsMenuItem updateUCSBMenuItem(@RequestParam Long id, @RequestBody @Valid @Valid UCSBDiningCommonsMenuItem incoming) Update a single menu item- Parameters:
id
- id of the menu item to updateincoming
- the new menu item- Returns:
- the updated menu item object
-
deleteUCSBMenuItem
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteUCSBMenuItem(@RequestParam Long id) Delete a menu item- Parameters:
id
- the id of the menu item to delete- Returns:
- a message indicating the menu item was deleted
-