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
This is a REST controller for UCSBOrganization
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionTHis method returns a list of all ucsborganizations.deleteOrganization
(String orgCode) Delete an organization.This method returns a single ucsborganization.postOrganisations
(String orgCode, String orgTranslationShort, String orgTranslation, boolean inactive) This method creates a new ucsborganizations.updateCommons
(String orgCode, @Valid UCSBOrganization incoming) Update a single ucsborganization.Methods inherited from class edu.ucsb.cs156.example.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
UCSBOrganizationController
public UCSBOrganizationController()
-
-
Method Details
-
allOrganisations
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<UCSBOrganization> allOrganisations()THis method returns a list of all ucsborganizations.- Returns:
- a list of all ucsborganizations
-
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public UCSBOrganization getById(@RequestParam String orgCode) This method returns a single ucsborganization.- Parameters:
orgCode
- code of the ucsborganization- Returns:
- a single ucsborganization
-
postOrganisations
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public UCSBOrganization postOrganisations(@RequestParam String orgCode, @RequestParam String orgTranslationShort, @RequestParam String orgTranslation, @RequestParam boolean inactive) This method creates a new ucsborganizations. Accessible only to users with the role "ROLE_ADMIN".- Parameters:
orgCode
- code of the ucsborganizationsorgTranslationShort
- short name of the organizationorgTranslation
- full name of the organizationinactive
- whether or not the organization is inactive- Returns:
- the saved ucsborganizations
-
updateCommons
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public UCSBOrganization updateCommons(@RequestParam String orgCode, @RequestBody @Valid @Valid UCSBOrganization incoming) Update a single ucsborganization. Accessible only to users with the role "ROLE_ADMIN".- Parameters:
orgCode
- code of the organizationincoming
- the new organization contents- Returns:
- the updated organization object
-
deleteOrganization
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteOrganization(@RequestParam String orgCode) Delete an organization. Accessible only to users with the role "ROLE_ADMIN".- Parameters:
orgCode
- code of the organization- Returns:
- a message indiciating the organization was deleted
-