Adds team and hunter leaderboard endpoints
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package net.halfbinary.scavengerhuntapi.controller
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation
|
||||
import net.halfbinary.scavengerhuntapi.model.HuntId
|
||||
import net.halfbinary.scavengerhuntapi.model.converter.toResponse
|
||||
import net.halfbinary.scavengerhuntapi.model.response.HunterLeaderboardResponse
|
||||
import net.halfbinary.scavengerhuntapi.model.response.TeamLeaderboardResponse
|
||||
import net.halfbinary.scavengerhuntapi.service.StatsService
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("stats/lead/hunt/{huntId}")
|
||||
class StatsController(private val statsService: StatsService) {
|
||||
|
||||
@GetMapping("/team")
|
||||
@Operation(summary = "Ranked teams with current total scores for a hunt")
|
||||
fun getTeamLeaderboard(@PathVariable huntId: HuntId): ResponseEntity<List<TeamLeaderboardResponse>> {
|
||||
return ResponseEntity.ok(statsService.getTeamLeaderboard(huntId).map { it.toResponse() })
|
||||
}
|
||||
|
||||
@GetMapping("/hunter")
|
||||
@Operation(summary = "Ranked hunters with current total scores for a hunt")
|
||||
fun getHunterLeaderboard(@PathVariable huntId: HuntId): ResponseEntity<List<HunterLeaderboardResponse>> {
|
||||
return ResponseEntity.ok(statsService.getHunterLeaderboard(huntId).map { it.toResponse() })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user