Class UCSBOrganizationController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.UCSBOrganizationController
@RequestMapping("/api/ucsborganizations")
@RestController
public class UCSBOrganizationController
extends ApiController
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThis method returns a list of all UCSB organizations.deleteOrganization
(String id, String orgCode) Delete a UCSB organization.This method returns a single UCSB organization.postOrganization
(String orgCode, String orgTranslationShort, String orgTranslation, boolean inactive) This method creates a new UCSB organization.updateOrganization
(String id, String orgCode, @Valid UCSBOrganization incoming) Update a single UCSB organization.Methods inherited from class edu.ucsb.cs156.example.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
UCSBOrganizationController
public UCSBOrganizationController()
-
-
Method Details
-
allOrganizations
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<UCSBOrganization> allOrganizations()This method returns a list of all UCSB organizations.- Returns:
- a list of all UCSB organizations
-
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public UCSBOrganization getById(@RequestParam(required=false) String id, @RequestParam(required=false) String orgCode) This method returns a single UCSB organization. Accepts both `id` and `orgCode` as parameters.- Parameters:
id
- the id of the UCSB organizationorgCode
- the orgCode of the UCSB organization- Returns:
- a single UCSB organization
-
postOrganization
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public UCSBOrganization postOrganization(@RequestParam String orgCode, @RequestParam String orgTranslationShort, @RequestParam String orgTranslation, @RequestParam boolean inactive) This method creates a new UCSB organization. Accessible only to users with the role "ROLE_ADMIN". -
deleteOrganization
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteOrganization(@RequestParam(required=false) String id, @RequestParam(required=false) String orgCode) Delete a UCSB organization. Accessible only to users with the role "ROLE_ADMIN". Accepts both `id` and `orgCode` as parameters. -
updateOrganization
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public UCSBOrganization updateOrganization(@RequestParam(required=false) String id, @RequestParam(required=true) String orgCode, @RequestBody @Valid @Valid UCSBOrganization incoming) Update a single UCSB organization. Accessible only to users with the role "ROLE_ADMIN". Accepts both `id` and `orgCode` as parameters.
-