Class UCSBDiningCommonsController

java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.UCSBDiningCommonsController

@RequestMapping("/api/ucsbdiningcommons") @RestController public class UCSBDiningCommonsController extends ApiController
This is a REST controller for UCSBDiningCommons
  • Constructor Details

    • UCSBDiningCommonsController

      public UCSBDiningCommonsController()
  • Method Details

    • allCommonss

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

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public UCSBDiningCommons 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 UCSBDiningCommons 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 UCSBDiningCommons updateCommons(@RequestParam String code, @RequestBody @Valid @Valid UCSBDiningCommons 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