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 Restaurants
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThis method returns a list of all restaurants.Deletes a restaurant.This method returns a single restaurant.postUCSBDiningCommonsMenuItem(String diningCommonsCode, String name, String station) This method creates a new restaurant.updateUCSBDiningCommonsMenuItem(Long id, @Valid UCSBDiningCommonsMenuItem incoming) Update a single restaurant.Methods inherited from class ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
UCSBDiningCommonsMenuItemController
public UCSBDiningCommonsMenuItemController()
-
-
Method Details
-
allUCSBDiningCommonsMenuItem
@PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/all") public Iterable<UCSBDiningCommonsMenuItem> allUCSBDiningCommonsMenuItem()This method returns a list of all restaurants.- Returns:
- a list of all restaurants
-
getById
@PreAuthorize("hasRole('ROLE_USER')") @GetMapping("") public UCSBDiningCommonsMenuItem getById(@RequestParam Long id) This method returns a single restaurant.- Parameters:
id- id of the restaurant to get- Returns:
- a single restaurant
-
postUCSBDiningCommonsMenuItem
@PreAuthorize("hasRole('ROLE_ADMIN')") @PostMapping("/post") public UCSBDiningCommonsMenuItem postUCSBDiningCommonsMenuItem(@RequestParam String diningCommonsCode, @RequestParam String name, @RequestParam String station) This method creates a new restaurant. Accessible only to users with the role "ROLE_ADMIN".- Parameters:
diningCommonsCode-name- name of the restaurantstation- description of the restaurant- Returns:
- the save restaurant (with it's id field set by the database)
-
deleteUCSBDiningCommonsMenuItem
@PreAuthorize("hasRole('ROLE_ADMIN')") @DeleteMapping("") public Object deleteUCSBDiningCommonsMenuItem(@RequestParam Long id) Deletes a restaurant. Accessible only to users with the role "ROLE_ADMIN".- Parameters:
id- id of the restaurant to delete- Returns:
- a message indicating that the restaurant was deleted
-
updateUCSBDiningCommonsMenuItem
@PreAuthorize("hasRole('ROLE_ADMIN')") @PutMapping("") public UCSBDiningCommonsMenuItem updateUCSBDiningCommonsMenuItem(@RequestParam Long id, @RequestBody @Valid @Valid UCSBDiningCommonsMenuItem incoming) Update a single restaurant. Accessible only to users with the role "ROLE_ADMIN".- Parameters:
id- id of the restaurant to updateincoming- the new restaurant contents- Returns:
- the updated restaurant object
-