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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionTHis method returns a list of all diningcommons.deleteCommons
(String code) Delete a diningcommons.This method returns a single diningcommons.postCommons
(String code, String name, boolean hasSackMeal, boolean hasTakeOutMeal, boolean hasDiningCam, double latitude, double longitude) This method creates a new diningcommons.updateCommons
(String code, @Valid DiningCommons incoming) Update a single diningcommons.Methods inherited from class edu.ucsb.cs156.dining.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
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 diningcommonsname
- name of the diningcommonshasSackMeal
- whether or not the commons has sack mealshasTakeOutMeal
- whether or not the commons has take out mealshasDiningCam
- whether or not the commons has a dining camlatitude
- latitude of the commonslongitude
- 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 diningcommonsincoming
- the new commons contents- Returns:
- the updated commons object
-