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
-
Method Summary
Modifier and TypeMethodDescriptionThis method returns a list of all ucsborganizations.deleteOrgs
(String orgCode) Delete an organization.This method returns a single organization.This method creates a new organiation.updateOrgs
(String orgCode, @Valid UCSBOrganizations incoming) Update a single org.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<UCSBOrganizations> allOrganizations()This method returns a list of all ucsborganizations.- Returns:
- a list of all ucsborganizations
-
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public UCSBOrganizations getById(@RequestParam String orgCode) This method returns a single organization.- Parameters:
orgCode
- code of the organization- Returns:
- a single organization
-
postOrgs
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public UCSBOrganizations postOrgs(@RequestParam String orgCode, @RequestParam String orgTranslationShort, @RequestParam String orgTranslation, @RequestParam boolean inactive) This method creates a new organiation. Accessible only to users with the role "ROLE_ADMIN".- Parameters:
orgCode
- code of the organizationorgTranslationShort
- short translation of the organizationorgTranslation
- translation of the organizationinactive
- whether the organization is inactive- Returns:
- the newly created organization
-
updateOrgs
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public UCSBOrganizations updateOrgs(@RequestParam String orgCode, @RequestBody @Valid @Valid UCSBOrganizations incoming) Update a single org. Accessible only to users with the role "ROLE_ADMIN".- Parameters:
orgCode
- the code of the org to updateincoming
- the new org contents- Returns:
- the updated org object
-
deleteOrgs
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteOrgs(@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
-