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 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 restaurant
      station - 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 update
      incoming - the new restaurant contents
      Returns:
      the updated restaurant object