diff options
| -rw-r--r-- | backend/controllers/mapController.go | 4 | ||||
| -rw-r--r-- | backend/database/games.sql | 6 | ||||
| -rw-r--r-- | backend/database/init.sql | 1 | ||||
| -rw-r--r-- | backend/models/models.go | 5 |
4 files changed, 9 insertions, 7 deletions
diff --git a/backend/controllers/mapController.go b/backend/controllers/mapController.go index 52b6623..11e56f6 100644 --- a/backend/controllers/mapController.go +++ b/backend/controllers/mapController.go | |||
| @@ -193,7 +193,7 @@ func FetchMapLeaderboards(c *gin.Context) { | |||
| 193 | // @Failure 400 {object} models.Response | 193 | // @Failure 400 {object} models.Response |
| 194 | // @Router /games [get] | 194 | // @Router /games [get] |
| 195 | func FetchGames(c *gin.Context) { | 195 | func FetchGames(c *gin.Context) { |
| 196 | rows, err := database.DB.Query(`SELECT id, name FROM games`) | 196 | rows, err := database.DB.Query(`SELECT id, name, is_coop FROM games`) |
| 197 | if err != nil { | 197 | if err != nil { |
| 198 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | 198 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) |
| 199 | return | 199 | return |
| @@ -201,7 +201,7 @@ func FetchGames(c *gin.Context) { | |||
| 201 | var games []models.Game | 201 | var games []models.Game |
| 202 | for rows.Next() { | 202 | for rows.Next() { |
| 203 | var game models.Game | 203 | var game models.Game |
| 204 | if err := rows.Scan(&game.ID, &game.Name); err != nil { | 204 | if err := rows.Scan(&game.ID, &game.Name, &game.IsCoop); err != nil { |
| 205 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | 205 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) |
| 206 | return | 206 | return |
| 207 | } | 207 | } |
diff --git a/backend/database/games.sql b/backend/database/games.sql index 5e2f4ee..0c2374c 100644 --- a/backend/database/games.sql +++ b/backend/database/games.sql | |||
| @@ -1,3 +1,3 @@ | |||
| 1 | INSERT INTO games(id, name) VALUES | 1 | INSERT INTO games(id, name, is_coop) VALUES |
| 2 | (1, 'Portal 2 - Singleplayer'), | 2 | (1, 'Portal 2 - Singleplayer', false), |
| 3 | (2, 'Portal 2 - Cooperative'); \ No newline at end of file | 3 | (2, 'Portal 2 - Cooperative', true); \ No newline at end of file |
diff --git a/backend/database/init.sql b/backend/database/init.sql index 76c3aa6..c7d098c 100644 --- a/backend/database/init.sql +++ b/backend/database/init.sql | |||
| @@ -11,6 +11,7 @@ CREATE TABLE users ( | |||
| 11 | CREATE TABLE games ( | 11 | CREATE TABLE games ( |
| 12 | id SMALLSERIAL, | 12 | id SMALLSERIAL, |
| 13 | name TEXT NOT NULL, | 13 | name TEXT NOT NULL, |
| 14 | is_coop BOOLEAN NOT NULL, | ||
| 14 | PRIMARY KEY (id) | 15 | PRIMARY KEY (id) |
| 15 | ); | 16 | ); |
| 16 | 17 | ||
diff --git a/backend/models/models.go b/backend/models/models.go index 2524935..e63ff91 100644 --- a/backend/models/models.go +++ b/backend/models/models.go | |||
| @@ -62,8 +62,9 @@ type UserRanking struct { | |||
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | type Game struct { | 64 | type Game struct { |
| 65 | ID int `json:"id"` | 65 | ID int `json:"id"` |
| 66 | Name string `json:"name"` | 66 | Name string `json:"name"` |
| 67 | IsCoop bool `json:"is_coop"` | ||
| 67 | } | 68 | } |
| 68 | 69 | ||
| 69 | type Chapter struct { | 70 | type Chapter struct { |