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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionTHis method returns a list of all ucsbdiningcommons.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 UCSBDiningCommons incoming) Update a single diningcommons.Methods inherited from class edu.ucsb.cs156.example.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
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 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 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 diningcommonsincoming
- the new commons contents- Returns:
- the updated commons object
-