Class CommonsController
java.lang.Object
edu.ucsb.cs156.happiercows.controllers.ApiController
edu.ucsb.cs156.happiercows.controllers.CommonsController
@RequestMapping("/api/commons")
@RestController
public class CommonsController
extends ApiController
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<String>
createCommons
(CreateCommonsParams params) deleteCommons
(Long id) deleteUserFromCommon
(Long commonsId, Long userId) org.springframework.http.ResponseEntity<String>
getCommonsById
(Long id) org.springframework.http.ResponseEntity<String>
getCommonsPlusById
(long id) org.springframework.http.ResponseEntity<String>
org.springframework.http.ResponseEntity<String>
joinCommon
(Long commonsId) org.springframework.http.ResponseEntity<String>
org.springframework.http.ResponseEntity<String>
updateCommons
(long id, CreateCommonsParams params) Methods inherited from class edu.ucsb.cs156.happiercows.controllers.ApiController
genericMessage, getCurrentUser, handleBadRequest, handleGenericException
-
Constructor Details
-
CommonsController
public CommonsController()
-
-
Method Details
-
getCommons
@GetMapping("/all") public org.springframework.http.ResponseEntity<String> getCommons() throws com.fasterxml.jackson.core.JsonProcessingException- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
getCommonsPlus
@GetMapping("/allplus") public org.springframework.http.ResponseEntity<String> getCommonsPlus() throws com.fasterxml.jackson.core.JsonProcessingException- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
getCommonsPlusById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/plus") public CommonsPlus getCommonsPlusById(@RequestParam long id) throws com.fasterxml.jackson.core.JsonProcessingException - Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
getDefaults
@GetMapping("/defaults") public org.springframework.http.ResponseEntity<String> getDefaults() throws com.fasterxml.jackson.core.JsonProcessingException- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
updateCommons
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("/update") public org.springframework.http.ResponseEntity<String> updateCommons(@RequestParam long id, @RequestBody CreateCommonsParams params) -
getCommonsById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public Commons getCommonsById(@RequestParam Long id) throws com.fasterxml.jackson.core.JsonProcessingException - Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
createCommons
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping(value="/new", produces="application/json") public org.springframework.http.ResponseEntity<String> createCommons(@RequestBody CreateCommonsParams params) throws com.fasterxml.jackson.core.JsonProcessingException - Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
listCowHealthUpdateStrategies
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all-health-update-strategies") public org.springframework.http.ResponseEntity<String> listCowHealthUpdateStrategies() throws com.fasterxml.jackson.core.JsonProcessingException- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
joinCommon
@PreAuthorize("hasRole(\'ROLE_USER\')") @PostMapping(value="/join", produces="application/json") public org.springframework.http.ResponseEntity<String> joinCommon(@RequestParam Long commonsId) throws Exception - Throws:
Exception
-
deleteCommons
-
deleteUserFromCommon
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("/{commonsId}/users/{userId}") public Object deleteUserFromCommon(@PathVariable("commonsId") Long commonsId, @PathVariable("userId") Long userId) throws Exception - Throws:
Exception
-