Class UCSBOrganizationController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.UCSBOrganizationController
@RequestMapping("/api/UCSBOrganization")
@RestController
public class UCSBOrganizationController
extends ApiController
REST endpoints for UCSB organizations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns all organizations for a logged-in user.deleteOrganization(String orgCode) Deletes an organization.Returns a single organization by its organization code.postOrganization(String orgCode, String orgTranslationShort, String orgTranslation, boolean inactive) Creates an organization.updateOrganization(String orgCode, @Valid UCSBOrganization incoming) Updates an organization's fields while retaining its organization code.Methods inherited from class ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
UCSBOrganizationController
public UCSBOrganizationController()
-
-
Method Details
-
allOrganizations
@PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/all") public Iterable<UCSBOrganization> allOrganizations()Returns all organizations for a logged-in user.- Returns:
- all organizations in the database
-
getById
@PreAuthorize("hasRole('ROLE_USER')") @GetMapping("") public UCSBOrganization getById(@RequestParam String orgCode) Returns a single organization by its organization code.- Parameters:
orgCode- the organization's unique code- Returns:
- the matching organization
-
postOrganization
@PreAuthorize("hasRole('ROLE_ADMIN')") @PostMapping("/post") public UCSBOrganization postOrganization(@RequestParam String orgCode, @RequestParam String orgTranslationShort, @RequestParam String orgTranslation, @RequestParam boolean inactive) Creates an organization. Only administrators may create organizations.- Parameters:
orgCode- the organization's unique codeorgTranslationShort- the organization's abbreviated nameorgTranslation- the organization's full nameinactive- whether the organization is inactive- Returns:
- the saved organization
-
deleteOrganization
-
updateOrganization
@PreAuthorize("hasRole('ROLE_ADMIN')") @PutMapping("") public UCSBOrganization updateOrganization(@RequestParam String orgCode, @RequestBody @Valid @Valid UCSBOrganization incoming) Updates an organization's fields while retaining its organization code.- Parameters:
orgCode- the code of the organization to updateincoming- the new organization field values- Returns:
- the updated organization
-