Class GameController

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

@RequestMapping("/api/game") @RestController public class GameController extends ApiController
  • Constructor Details

    • GameController

      public GameController()
  • Method Details

    • getDefaultGame

      @GetMapping("/defaults") public org.springframework.http.ResponseEntity<Game> getDefaultGame() throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • getGame

      @GetMapping("/all") public org.springframework.http.ResponseEntity<String> getGame() throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • getGamePlus

      @GetMapping("/allplus") public org.springframework.http.ResponseEntity<String> getGamePlus() throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • getGamePlusById

      @PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/plus") public GamePlus getGamePlusById(@RequestParam long id) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • updateGame

      @PreAuthorize("hasRole('ROLE_ADMIN')") @PutMapping("/update") public org.springframework.http.ResponseEntity<String> updateGame(@RequestParam long id, @RequestBody CreateGameParams params)
    • getGameById

      @PreAuthorize("hasRole('ROLE_USER')") @GetMapping("") public Game getGameById(@RequestParam Long id) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • createGame

      @PreAuthorize("hasRole('ROLE_ADMIN')") @PostMapping(value="/new", produces="application/json") public org.springframework.http.ResponseEntity<String> createGame(@RequestBody CreateGameParams params) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • validateDates

      public static void validateDates(CreateGameParams params)
      Enforce that both dates are present and that the last date is strictly after the starting date. (See issue #250; the frontend form enforces the same rules, but the backend must not rely on that.)
      Parameters:
      params - the params to validate
    • 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
    • getMyCourseIds

      @PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/mycourses") public org.springframework.http.ResponseEntity<List<Long>> getMyCourseIds()
    • joinCommon

      @PreAuthorize("hasRole('ROLE_USER')") @PostMapping(value="/join", produces="application/json") public org.springframework.http.ResponseEntity<String> joinCommon(@RequestParam Long gameId) throws Exception
      Throws:
      Exception
    • deleteGame

      @PreAuthorize("hasRole('ROLE_ADMIN')") @DeleteMapping("") public Object deleteGame(@RequestParam Long id)
    • deleteUserFromCommon

      @PreAuthorize("hasRole('ROLE_ADMIN')") @DeleteMapping("/{gameId}/users/{userId}") public Object deleteUserFromCommon(@PathVariable("gameId") Long gameId, @PathVariable("userId") Long userId) throws Exception
      Throws:
      Exception
    • updateDashboardSettings

      @PreAuthorize("hasRole('ROLE_ADMIN')") @PutMapping("/dashboardSettings") public org.springframework.http.ResponseEntity<Game> updateDashboardSettings(@RequestParam long id, @RequestBody DashboardSettingsParams params)
    • getNumCowsForGameId

      @PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/numcows") public org.springframework.http.ResponseEntity<List<Integer>> getNumCowsForGameId(@RequestParam Long gameId)
    • getGameTimeSeries

      @PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/timeseries") public org.springframework.http.ResponseEntity<List<Map<String,Object>>> getGameTimeSeries(@RequestParam Long commonId)