Class HerdController

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

@RequestMapping("/api/herds") @RestController public class HerdController extends ApiController
  • Constructor Details

    • HerdController

      public HerdController()
  • Method Details

    • getHerdsByGameIdAndUserId

      @PreAuthorize("hasRole('ROLE_ADMIN')") @GetMapping("") public Iterable<Herd> getHerdsByGameIdAndUserId(@RequestParam Long gameId, @RequestParam Long userId)
    • getHerdsForCurrentUser

      @PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/forcurrentuser") public Iterable<Herd> getHerdsForCurrentUser(@RequestParam Long gameId)
      The userId is always taken from the logged-in user, never from a request parameter, so a farmer can only ever read their own herds.