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 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 item
      station - 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 update
      incoming - the new menu item values
      Returns:
      the updated menu item