Class FarmerController
java.lang.Object
edu.ucsb.cs156.happiercows.controllers.ApiController
edu.ucsb.cs156.happiercows.controllers.FarmerController
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetFarmerById(Long gameId) getFarmerById(Long userId, Long gameId) getFarmersByGameId(Long gameId) org.springframework.http.ResponseEntity<String> putFarmerByIdBuy(Long gameId, int numCows) org.springframework.http.ResponseEntity<String> putFarmerByIdSell(Long gameId, int numCows) org.springframework.http.ResponseEntity<String> sellCowsFromHerd(Long gameId, Long herdId, int numCows) Methods inherited from class ApiController
genericMessage, getCurrentUser, handleBadRequest, handleForbidden, handleGenericException
-
Constructor Details
-
FarmerController
public FarmerController()
-
-
Method Details
-
getFarmerById
-
getFarmerById
-
putFarmerByIdBuy
@PreAuthorize("hasRole('ROLE_USER')") @PutMapping("/buy") public org.springframework.http.ResponseEntity<String> putFarmerByIdBuy(@RequestParam Long gameId, @RequestParam int numCows) throws NotEnoughMoneyException, com.fasterxml.jackson.core.JsonProcessingException - Throws:
NotEnoughMoneyExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
putFarmerByIdSell
@PreAuthorize("hasRole('ROLE_USER')") @PutMapping("/sell") public org.springframework.http.ResponseEntity<String> putFarmerByIdSell(@RequestParam Long gameId, @RequestParam int numCows) throws NoCowsException, com.fasterxml.jackson.core.JsonProcessingException - Throws:
NoCowsExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
sellCowsFromHerd
@PreAuthorize("hasRole('ROLE_USER')") @PutMapping("/sell/herd") @Transactional public org.springframework.http.ResponseEntity<String> sellCowsFromHerd(@RequestParam Long gameId, @RequestParam Long herdId, @RequestParam int numCows) throws NoCowsException, com.fasterxml.jackson.core.JsonProcessingException - Throws:
NoCowsExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
getFarmersByGameId
@PreAuthorize("hasAnyRole('ROLE_USER', 'ROLE_ADMIN')") @GetMapping("/game/all") public List<FarmerWithStudentStatus> getFarmersByGameId(@RequestParam Long gameId)
-