diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-22 23:58:26 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-22 23:58:26 +0300 |
| commit | 9cd44de9be62e1291f84763bc029f995301e1e03 (patch) | |
| tree | 5b4b8bc6d7a89173373fbb32c5a8c5013f8c9d82 /backend/handlers/map.go | |
| parent | feat: map search (#78) (diff) | |
| download | lphub-9cd44de9be62e1291f84763bc029f995301e1e03.tar.gz lphub-9cd44de9be62e1291f84763bc029f995301e1e03.tar.bz2 lphub-9cd44de9be62e1291f84763bc029f995301e1e03.zip | |
feat: discussions (#59)
Former-commit-id: ac6ac59367650b6a37650f5aec0587c6ce4d3dd1
Diffstat (limited to 'backend/handlers/map.go')
| -rw-r--r-- | backend/handlers/map.go | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/backend/handlers/map.go b/backend/handlers/map.go index f3198ff..3bf14cd 100644 --- a/backend/handlers/map.go +++ b/backend/handlers/map.go | |||
| @@ -58,12 +58,11 @@ type RecordMultiplayer struct { | |||
| 58 | // @Description Get map summary with specified id. | 58 | // @Description Get map summary with specified id. |
| 59 | // @Tags maps | 59 | // @Tags maps |
| 60 | // @Produce json | 60 | // @Produce json |
| 61 | // @Param id path int true "Map ID" | 61 | // @Param mapid path int true "Map ID" |
| 62 | // @Success 200 {object} models.Response{data=MapSummaryResponse} | 62 | // @Success 200 {object} models.Response{data=MapSummaryResponse} |
| 63 | // @Failure 400 {object} models.Response | 63 | // @Router /maps/{mapid}/summary [get] |
| 64 | // @Router /maps/{id}/summary [get] | ||
| 65 | func FetchMapSummary(c *gin.Context) { | 64 | func FetchMapSummary(c *gin.Context) { |
| 66 | id := c.Param("id") | 65 | id := c.Param("mapid") |
| 67 | response := MapSummaryResponse{Map: models.Map{}, Summary: models.MapSummary{Routes: []models.MapRoute{}}} | 66 | response := MapSummaryResponse{Map: models.Map{}, Summary: models.MapSummary{Routes: []models.MapRoute{}}} |
| 68 | intID, err := strconv.Atoi(id) | 67 | intID, err := strconv.Atoi(id) |
| 69 | if err != nil { | 68 | if err != nil { |
| @@ -138,14 +137,13 @@ func FetchMapSummary(c *gin.Context) { | |||
| 138 | // @Description Get map leaderboards with specified id. | 137 | // @Description Get map leaderboards with specified id. |
| 139 | // @Tags maps | 138 | // @Tags maps |
| 140 | // @Produce json | 139 | // @Produce json |
| 141 | // @Param id path int true "Map ID" | 140 | // @Param mapid path int true "Map ID" |
| 142 | // @Param page query int false "Page Number (default: 1)" | 141 | // @Param page query int false "Page Number (default: 1)" |
| 143 | // @Param pageSize query int false "Number of Records Per Page (default: 20)" | 142 | // @Param pageSize query int false "Number of Records Per Page (default: 20)" |
| 144 | // @Success 200 {object} models.Response{data=MapLeaderboardsResponse} | 143 | // @Success 200 {object} models.Response{data=MapLeaderboardsResponse} |
| 145 | // @Failure 400 {object} models.Response | 144 | // @Router /maps/{mapid}/leaderboards [get] |
| 146 | // @Router /maps/{id}/leaderboards [get] | ||
| 147 | func FetchMapLeaderboards(c *gin.Context) { | 145 | func FetchMapLeaderboards(c *gin.Context) { |
| 148 | id := c.Param("id") | 146 | id := c.Param("mapid") |
| 149 | // Get map data | 147 | // Get map data |
| 150 | response := MapLeaderboardsResponse{Map: models.Map{}, Records: nil, Pagination: models.Pagination{}} | 148 | response := MapLeaderboardsResponse{Map: models.Map{}, Records: nil, Pagination: models.Pagination{}} |
| 151 | page, err := strconv.Atoi(c.DefaultQuery("page", "1")) | 149 | page, err := strconv.Atoi(c.DefaultQuery("page", "1")) |
| @@ -349,12 +347,11 @@ func FetchGames(c *gin.Context) { | |||
| 349 | // @Description Get chapters from the specified game id. | 347 | // @Description Get chapters from the specified game id. |
| 350 | // @Tags games & chapters | 348 | // @Tags games & chapters |
| 351 | // @Produce json | 349 | // @Produce json |
| 352 | // @Param id path int true "Game ID" | 350 | // @Param gameid path int true "Game ID" |
| 353 | // @Success 200 {object} models.Response{data=ChaptersResponse} | 351 | // @Success 200 {object} models.Response{data=ChaptersResponse} |
| 354 | // @Failure 400 {object} models.Response | 352 | // @Router /games/{gameid} [get] |
| 355 | // @Router /games/{id} [get] | ||
| 356 | func FetchChapters(c *gin.Context) { | 353 | func FetchChapters(c *gin.Context) { |
| 357 | gameID := c.Param("id") | 354 | gameID := c.Param("gameid") |
| 358 | intID, err := strconv.Atoi(gameID) | 355 | intID, err := strconv.Atoi(gameID) |
| 359 | if err != nil { | 356 | if err != nil { |
| 360 | c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) | 357 | c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) |
| @@ -391,12 +388,12 @@ func FetchChapters(c *gin.Context) { | |||
| 391 | // @Description Get maps from the specified chapter id. | 388 | // @Description Get maps from the specified chapter id. |
| 392 | // @Tags games & chapters | 389 | // @Tags games & chapters |
| 393 | // @Produce json | 390 | // @Produce json |
| 394 | // @Param id path int true "Chapter ID" | 391 | // @Param chapterid path int true "Chapter ID" |
| 395 | // @Success 200 {object} models.Response{data=ChapterMapsResponse} | 392 | // @Success 200 {object} models.Response{data=ChapterMapsResponse} |
| 396 | // @Failure 400 {object} models.Response | 393 | // @Failure 400 {object} models.Response |
| 397 | // @Router /chapters/{id} [get] | 394 | // @Router /chapters/{chapterid} [get] |
| 398 | func FetchChapterMaps(c *gin.Context) { | 395 | func FetchChapterMaps(c *gin.Context) { |
| 399 | chapterID := c.Param("id") | 396 | chapterID := c.Param("chapterid") |
| 400 | intID, err := strconv.Atoi(chapterID) | 397 | intID, err := strconv.Atoi(chapterID) |
| 401 | if err != nil { | 398 | if err != nil { |
| 402 | c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) | 399 | c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) |