Class FarmerController

java.lang.Object
edu.ucsb.cs156.happiercows.controllers.ApiController
edu.ucsb.cs156.happiercows.controllers.FarmerController

@RequestMapping("/api/farmer") @RestController public class FarmerController extends ApiController
  • Constructor Details

    • FarmerController

      public FarmerController()
  • Method Details

    • getFarmerById

      @PreAuthorize("hasRole('ROLE_ADMIN')") @GetMapping("") public Farmer getFarmerById(@RequestParam Long userId, @RequestParam Long gameId) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • getFarmerById

      @PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/forcurrentuser") public Farmer getFarmerById(@RequestParam Long gameId) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • 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:
      NotEnoughMoneyException
      com.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:
      NoCowsException
      com.fasterxml.jackson.core.JsonProcessingException
    • getFarmersByGameId

      @PreAuthorize("hasAnyRole('ROLE_USER', 'ROLE_ADMIN')") @GetMapping("/game/all") public List<FarmerWithStudentStatus> getFarmersByGameId(@RequestParam Long gameId)