Class DiningCommonsController

java.lang.Object
edu.ucsb.cs156.dining.controllers.ApiController
edu.ucsb.cs156.dining.controllers.DiningCommonsController

@RequestMapping("/api/diningcommons") @RestController public class DiningCommonsController extends ApiController
This is a REST controller for DiningCommons
  • Constructor Details

    • DiningCommonsController

      public DiningCommonsController()
  • Method Details

    • allCommonss

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<DiningCommons> allCommonss()
      THis method returns a list of all diningcommons.
      Returns:
      a list of all diningcommons
    • getById

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public DiningCommons getById(@RequestParam String code)
      This method returns a single diningcommons.
      Parameters:
      code - code of the diningcommons
      Returns:
      a single diningcommons
    • postCommons

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public DiningCommons postCommons(@RequestParam String code, @RequestParam String name, @RequestParam boolean hasSackMeal, @RequestParam boolean hasTakeOutMeal, @RequestParam boolean hasDiningCam, @RequestParam double latitude, @RequestParam double longitude)
      This method creates a new diningcommons. Accessible only to users with the role "ROLE_ADMIN".
      Parameters:
      code - code of the diningcommons
      name - name of the diningcommons
      hasSackMeal - whether or not the commons has sack meals
      hasTakeOutMeal - whether or not the commons has take out meals
      hasDiningCam - whether or not the commons has a dining cam
      latitude - latitude of the commons
      longitude - logitude of the commons
      Returns:
      the save diningcommons
    • deleteCommons

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteCommons(@RequestParam String code)
      Delete a diningcommons. Accessible only to users with the role "ROLE_ADMIN".
      Parameters:
      code - code of the commons
      Returns:
      a message indiciating the commons was deleted
    • updateCommons

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public DiningCommons updateCommons(@RequestParam String code, @RequestBody @Valid @Valid DiningCommons incoming)
      Update a single diningcommons. Accessible only to users with the role "ROLE_ADMIN".
      Parameters:
      code - code of the diningcommons
      incoming - the new commons contents
      Returns:
      the updated commons object