diff options
Diffstat (limited to '')
| -rw-r--r-- | backend/handlers/logs.go | 17 | ||||
| -rw-r--r-- | docs/docs.go | 130 | ||||
| -rw-r--r-- | docs/swagger.json | 130 | ||||
| -rw-r--r-- | docs/swagger.yaml | 80 |
4 files changed, 351 insertions, 6 deletions
diff --git a/backend/handlers/logs.go b/backend/handlers/logs.go index 0ebba47..5233738 100644 --- a/backend/handlers/logs.go +++ b/backend/handlers/logs.go | |||
| @@ -49,6 +49,15 @@ type ScoreLogsResponseDetails struct { | |||
| 49 | Date time.Time `json:"date"` | 49 | Date time.Time `json:"date"` |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | // GET Mod Logs | ||
| 53 | // | ||
| 54 | // @Description Get mod logs. | ||
| 55 | // @Tags rankings | ||
| 56 | // @Produce json | ||
| 57 | // @Param Authorization header string true "JWT Token" | ||
| 58 | // @Success 200 {object} models.Response{data=ScoreLogsResponse} | ||
| 59 | // @Failure 400 {object} models.Response | ||
| 60 | // @Router /logs/mod [get] | ||
| 52 | func ModLogs(c *gin.Context) { | 61 | func ModLogs(c *gin.Context) { |
| 53 | mod, exists := c.Get("mod") | 62 | mod, exists := c.Get("mod") |
| 54 | if !exists || !mod.(bool) { | 63 | if !exists || !mod.(bool) { |
| @@ -86,6 +95,14 @@ func ModLogs(c *gin.Context) { | |||
| 86 | }) | 95 | }) |
| 87 | } | 96 | } |
| 88 | 97 | ||
| 98 | // GET Score Logs | ||
| 99 | // | ||
| 100 | // @Description Get score logs of every player. | ||
| 101 | // @Tags rankings | ||
| 102 | // @Produce json | ||
| 103 | // @Success 200 {object} models.Response{data=ScoreLogsResponse} | ||
| 104 | // @Failure 400 {object} models.Response | ||
| 105 | // @Router /logs/score [get] | ||
| 89 | func ScoreLogs(c *gin.Context) { | 106 | func ScoreLogs(c *gin.Context) { |
| 90 | response := ScoreLogsResponse{Logs: []ScoreLogsResponseDetails{}} | 107 | response := ScoreLogsResponse{Logs: []ScoreLogsResponseDetails{}} |
| 91 | sql := `SELECT g.id, | 108 | sql := `SELECT g.id, |
diff --git a/docs/docs.go b/docs/docs.go index 72a1434..3d140cc 100644 --- a/docs/docs.go +++ b/docs/docs.go | |||
| @@ -229,6 +229,89 @@ const docTemplate = `{ | |||
| 229 | } | 229 | } |
| 230 | } | 230 | } |
| 231 | }, | 231 | }, |
| 232 | "/logs/mod": { | ||
| 233 | "get": { | ||
| 234 | "description": "Get mod logs.", | ||
| 235 | "produces": [ | ||
| 236 | "application/json" | ||
| 237 | ], | ||
| 238 | "tags": [ | ||
| 239 | "rankings" | ||
| 240 | ], | ||
| 241 | "parameters": [ | ||
| 242 | { | ||
| 243 | "type": "string", | ||
| 244 | "description": "JWT Token", | ||
| 245 | "name": "Authorization", | ||
| 246 | "in": "header", | ||
| 247 | "required": true | ||
| 248 | } | ||
| 249 | ], | ||
| 250 | "responses": { | ||
| 251 | "200": { | ||
| 252 | "description": "OK", | ||
| 253 | "schema": { | ||
| 254 | "allOf": [ | ||
| 255 | { | ||
| 256 | "$ref": "#/definitions/models.Response" | ||
| 257 | }, | ||
| 258 | { | ||
| 259 | "type": "object", | ||
| 260 | "properties": { | ||
| 261 | "data": { | ||
| 262 | "$ref": "#/definitions/handlers.ScoreLogsResponse" | ||
| 263 | } | ||
| 264 | } | ||
| 265 | } | ||
| 266 | ] | ||
| 267 | } | ||
| 268 | }, | ||
| 269 | "400": { | ||
| 270 | "description": "Bad Request", | ||
| 271 | "schema": { | ||
| 272 | "$ref": "#/definitions/models.Response" | ||
| 273 | } | ||
| 274 | } | ||
| 275 | } | ||
| 276 | } | ||
| 277 | }, | ||
| 278 | "/logs/score": { | ||
| 279 | "get": { | ||
| 280 | "description": "Get score logs of every player.", | ||
| 281 | "produces": [ | ||
| 282 | "application/json" | ||
| 283 | ], | ||
| 284 | "tags": [ | ||
| 285 | "rankings" | ||
| 286 | ], | ||
| 287 | "responses": { | ||
| 288 | "200": { | ||
| 289 | "description": "OK", | ||
| 290 | "schema": { | ||
| 291 | "allOf": [ | ||
| 292 | { | ||
| 293 | "$ref": "#/definitions/models.Response" | ||
| 294 | }, | ||
| 295 | { | ||
| 296 | "type": "object", | ||
| 297 | "properties": { | ||
| 298 | "data": { | ||
| 299 | "$ref": "#/definitions/handlers.ScoreLogsResponse" | ||
| 300 | } | ||
| 301 | } | ||
| 302 | } | ||
| 303 | ] | ||
| 304 | } | ||
| 305 | }, | ||
| 306 | "400": { | ||
| 307 | "description": "Bad Request", | ||
| 308 | "schema": { | ||
| 309 | "$ref": "#/definitions/models.Response" | ||
| 310 | } | ||
| 311 | } | ||
| 312 | } | ||
| 313 | } | ||
| 314 | }, | ||
| 232 | "/maps/{id}/image": { | 315 | "/maps/{id}/image": { |
| 233 | "put": { | 316 | "put": { |
| 234 | "description": "Edit map image with specified map id.", | 317 | "description": "Edit map image with specified map id.", |
| @@ -1267,13 +1350,19 @@ const docTemplate = `{ | |||
| 1267 | "handlers.RankingsResponse": { | 1350 | "handlers.RankingsResponse": { |
| 1268 | "type": "object", | 1351 | "type": "object", |
| 1269 | "properties": { | 1352 | "properties": { |
| 1270 | "rankings_mp": { | 1353 | "rankings_multiplayer": { |
| 1354 | "type": "array", | ||
| 1355 | "items": { | ||
| 1356 | "$ref": "#/definitions/models.UserRanking" | ||
| 1357 | } | ||
| 1358 | }, | ||
| 1359 | "rankings_overall": { | ||
| 1271 | "type": "array", | 1360 | "type": "array", |
| 1272 | "items": { | 1361 | "items": { |
| 1273 | "$ref": "#/definitions/models.UserRanking" | 1362 | "$ref": "#/definitions/models.UserRanking" |
| 1274 | } | 1363 | } |
| 1275 | }, | 1364 | }, |
| 1276 | "rankings_sp": { | 1365 | "rankings_singleplayer": { |
| 1277 | "type": "array", | 1366 | "type": "array", |
| 1278 | "items": { | 1367 | "items": { |
| 1279 | "$ref": "#/definitions/models.UserRanking" | 1368 | "$ref": "#/definitions/models.UserRanking" |
| @@ -1292,6 +1381,43 @@ const docTemplate = `{ | |||
| 1292 | } | 1381 | } |
| 1293 | } | 1382 | } |
| 1294 | }, | 1383 | }, |
| 1384 | "handlers.ScoreLogsResponse": { | ||
| 1385 | "type": "object", | ||
| 1386 | "properties": { | ||
| 1387 | "scores": { | ||
| 1388 | "type": "array", | ||
| 1389 | "items": { | ||
| 1390 | "$ref": "#/definitions/handlers.ScoreLogsResponseDetails" | ||
| 1391 | } | ||
| 1392 | } | ||
| 1393 | } | ||
| 1394 | }, | ||
| 1395 | "handlers.ScoreLogsResponseDetails": { | ||
| 1396 | "type": "object", | ||
| 1397 | "properties": { | ||
| 1398 | "date": { | ||
| 1399 | "type": "string" | ||
| 1400 | }, | ||
| 1401 | "demo_id": { | ||
| 1402 | "type": "string" | ||
| 1403 | }, | ||
| 1404 | "game": { | ||
| 1405 | "$ref": "#/definitions/models.Game" | ||
| 1406 | }, | ||
| 1407 | "map": { | ||
| 1408 | "$ref": "#/definitions/models.MapShort" | ||
| 1409 | }, | ||
| 1410 | "score_count": { | ||
| 1411 | "type": "integer" | ||
| 1412 | }, | ||
| 1413 | "score_time": { | ||
| 1414 | "type": "integer" | ||
| 1415 | }, | ||
| 1416 | "user": { | ||
| 1417 | "$ref": "#/definitions/models.UserShort" | ||
| 1418 | } | ||
| 1419 | } | ||
| 1420 | }, | ||
| 1295 | "handlers.SearchResponse": { | 1421 | "handlers.SearchResponse": { |
| 1296 | "type": "object", | 1422 | "type": "object", |
| 1297 | "properties": { | 1423 | "properties": { |
diff --git a/docs/swagger.json b/docs/swagger.json index 6fbe02e..f55190e 100644 --- a/docs/swagger.json +++ b/docs/swagger.json | |||
| @@ -222,6 +222,89 @@ | |||
| 222 | } | 222 | } |
| 223 | } | 223 | } |
| 224 | }, | 224 | }, |
| 225 | "/logs/mod": { | ||
| 226 | "get": { | ||
| 227 | "description": "Get mod logs.", | ||
| 228 | "produces": [ | ||
| 229 | "application/json" | ||
| 230 | ], | ||
| 231 | "tags": [ | ||
| 232 | "rankings" | ||
| 233 | ], | ||
| 234 | "parameters": [ | ||
| 235 | { | ||
| 236 | "type": "string", | ||
| 237 | "description": "JWT Token", | ||
| 238 | "name": "Authorization", | ||
| 239 | "in": "header", | ||
| 240 | "required": true | ||
| 241 | } | ||
| 242 | ], | ||
| 243 | "responses": { | ||
| 244 | "200": { | ||
| 245 | "description": "OK", | ||
| 246 | "schema": { | ||
| 247 | "allOf": [ | ||
| 248 | { | ||
| 249 | "$ref": "#/definitions/models.Response" | ||
| 250 | }, | ||
| 251 | { | ||
| 252 | "type": "object", | ||
| 253 | "properties": { | ||
| 254 | "data": { | ||
| 255 | "$ref": "#/definitions/handlers.ScoreLogsResponse" | ||
| 256 | } | ||
| 257 | } | ||
| 258 | } | ||
| 259 | ] | ||
| 260 | } | ||
| 261 | }, | ||
| 262 | "400": { | ||
| 263 | "description": "Bad Request", | ||
| 264 | "schema": { | ||
| 265 | "$ref": "#/definitions/models.Response" | ||
| 266 | } | ||
| 267 | } | ||
| 268 | } | ||
| 269 | } | ||
| 270 | }, | ||
| 271 | "/logs/score": { | ||
| 272 | "get": { | ||
| 273 | "description": "Get score logs of every player.", | ||
| 274 | "produces": [ | ||
| 275 | "application/json" | ||
| 276 | ], | ||
| 277 | "tags": [ | ||
| 278 | "rankings" | ||
| 279 | ], | ||
| 280 | "responses": { | ||
| 281 | "200": { | ||
| 282 | "description": "OK", | ||
| 283 | "schema": { | ||
| 284 | "allOf": [ | ||
| 285 | { | ||
| 286 | "$ref": "#/definitions/models.Response" | ||
| 287 | }, | ||
| 288 | { | ||
| 289 | "type": "object", | ||
| 290 | "properties": { | ||
| 291 | "data": { | ||
| 292 | "$ref": "#/definitions/handlers.ScoreLogsResponse" | ||
| 293 | } | ||
| 294 | } | ||
| 295 | } | ||
| 296 | ] | ||
| 297 | } | ||
| 298 | }, | ||
| 299 | "400": { | ||
| 300 | "description": "Bad Request", | ||
| 301 | "schema": { | ||
| 302 | "$ref": "#/definitions/models.Response" | ||
| 303 | } | ||
| 304 | } | ||
| 305 | } | ||
| 306 | } | ||
| 307 | }, | ||
| 225 | "/maps/{id}/image": { | 308 | "/maps/{id}/image": { |
| 226 | "put": { | 309 | "put": { |
| 227 | "description": "Edit map image with specified map id.", | 310 | "description": "Edit map image with specified map id.", |
| @@ -1260,13 +1343,19 @@ | |||
| 1260 | "handlers.RankingsResponse": { | 1343 | "handlers.RankingsResponse": { |
| 1261 | "type": "object", | 1344 | "type": "object", |
| 1262 | "properties": { | 1345 | "properties": { |
| 1263 | "rankings_mp": { | 1346 | "rankings_multiplayer": { |
| 1347 | "type": "array", | ||
| 1348 | "items": { | ||
| 1349 | "$ref": "#/definitions/models.UserRanking" | ||
| 1350 | } | ||
| 1351 | }, | ||
| 1352 | "rankings_overall": { | ||
| 1264 | "type": "array", | 1353 | "type": "array", |
| 1265 | "items": { | 1354 | "items": { |
| 1266 | "$ref": "#/definitions/models.UserRanking" | 1355 | "$ref": "#/definitions/models.UserRanking" |
| 1267 | } | 1356 | } |
| 1268 | }, | 1357 | }, |
| 1269 | "rankings_sp": { | 1358 | "rankings_singleplayer": { |
| 1270 | "type": "array", | 1359 | "type": "array", |
| 1271 | "items": { | 1360 | "items": { |
| 1272 | "$ref": "#/definitions/models.UserRanking" | 1361 | "$ref": "#/definitions/models.UserRanking" |
| @@ -1285,6 +1374,43 @@ | |||
| 1285 | } | 1374 | } |
| 1286 | } | 1375 | } |
| 1287 | }, | 1376 | }, |
| 1377 | "handlers.ScoreLogsResponse": { | ||
| 1378 | "type": "object", | ||
| 1379 | "properties": { | ||
| 1380 | "scores": { | ||
| 1381 | "type": "array", | ||
| 1382 | "items": { | ||
| 1383 | "$ref": "#/definitions/handlers.ScoreLogsResponseDetails" | ||
| 1384 | } | ||
| 1385 | } | ||
| 1386 | } | ||
| 1387 | }, | ||
| 1388 | "handlers.ScoreLogsResponseDetails": { | ||
| 1389 | "type": "object", | ||
| 1390 | "properties": { | ||
| 1391 | "date": { | ||
| 1392 | "type": "string" | ||
| 1393 | }, | ||
| 1394 | "demo_id": { | ||
| 1395 | "type": "string" | ||
| 1396 | }, | ||
| 1397 | "game": { | ||
| 1398 | "$ref": "#/definitions/models.Game" | ||
| 1399 | }, | ||
| 1400 | "map": { | ||
| 1401 | "$ref": "#/definitions/models.MapShort" | ||
| 1402 | }, | ||
| 1403 | "score_count": { | ||
| 1404 | "type": "integer" | ||
| 1405 | }, | ||
| 1406 | "score_time": { | ||
| 1407 | "type": "integer" | ||
| 1408 | }, | ||
| 1409 | "user": { | ||
| 1410 | "$ref": "#/definitions/models.UserShort" | ||
| 1411 | } | ||
| 1412 | } | ||
| 1413 | }, | ||
| 1288 | "handlers.SearchResponse": { | 1414 | "handlers.SearchResponse": { |
| 1289 | "type": "object", | 1415 | "type": "object", |
| 1290 | "properties": { | 1416 | "properties": { |
diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 4b59ee9..4d5661e 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml | |||
| @@ -165,11 +165,15 @@ definitions: | |||
| 165 | type: object | 165 | type: object |
| 166 | handlers.RankingsResponse: | 166 | handlers.RankingsResponse: |
| 167 | properties: | 167 | properties: |
| 168 | rankings_mp: | 168 | rankings_multiplayer: |
| 169 | items: | 169 | items: |
| 170 | $ref: '#/definitions/models.UserRanking' | 170 | $ref: '#/definitions/models.UserRanking' |
| 171 | type: array | 171 | type: array |
| 172 | rankings_sp: | 172 | rankings_overall: |
| 173 | items: | ||
| 174 | $ref: '#/definitions/models.UserRanking' | ||
| 175 | type: array | ||
| 176 | rankings_singleplayer: | ||
| 173 | items: | 177 | items: |
| 174 | $ref: '#/definitions/models.UserRanking' | 178 | $ref: '#/definitions/models.UserRanking' |
| 175 | type: array | 179 | type: array |
| @@ -181,6 +185,30 @@ definitions: | |||
| 181 | score_time: | 185 | score_time: |
| 182 | type: integer | 186 | type: integer |
| 183 | type: object | 187 | type: object |
| 188 | handlers.ScoreLogsResponse: | ||
| 189 | properties: | ||
| 190 | scores: | ||
| 191 | items: | ||
| 192 | $ref: '#/definitions/handlers.ScoreLogsResponseDetails' | ||
| 193 | type: array | ||
| 194 | type: object | ||
| 195 | handlers.ScoreLogsResponseDetails: | ||
| 196 | properties: | ||
| 197 | date: | ||
| 198 | type: string | ||
| 199 | demo_id: | ||
| 200 | type: string | ||
| 201 | game: | ||
| 202 | $ref: '#/definitions/models.Game' | ||
| 203 | map: | ||
| 204 | $ref: '#/definitions/models.MapShort' | ||
| 205 | score_count: | ||
| 206 | type: integer | ||
| 207 | score_time: | ||
| 208 | type: integer | ||
| 209 | user: | ||
| 210 | $ref: '#/definitions/models.UserShort' | ||
| 211 | type: object | ||
| 184 | handlers.SearchResponse: | 212 | handlers.SearchResponse: |
| 185 | properties: | 213 | properties: |
| 186 | maps: | 214 | maps: |
| @@ -444,6 +472,54 @@ paths: | |||
| 444 | $ref: '#/definitions/models.Response' | 472 | $ref: '#/definitions/models.Response' |
| 445 | tags: | 473 | tags: |
| 446 | - login | 474 | - login |
| 475 | /logs/mod: | ||
| 476 | get: | ||
| 477 | description: Get mod logs. | ||
| 478 | parameters: | ||
| 479 | - description: JWT Token | ||
| 480 | in: header | ||
| 481 | name: Authorization | ||
| 482 | required: true | ||
| 483 | type: string | ||
| 484 | produces: | ||
| 485 | - application/json | ||
| 486 | responses: | ||
| 487 | "200": | ||
| 488 | description: OK | ||
| 489 | schema: | ||
| 490 | allOf: | ||
| 491 | - $ref: '#/definitions/models.Response' | ||
| 492 | - properties: | ||
| 493 | data: | ||
| 494 | $ref: '#/definitions/handlers.ScoreLogsResponse' | ||
| 495 | type: object | ||
| 496 | "400": | ||
| 497 | description: Bad Request | ||
| 498 | schema: | ||
| 499 | $ref: '#/definitions/models.Response' | ||
| 500 | tags: | ||
| 501 | - rankings | ||
| 502 | /logs/score: | ||
| 503 | get: | ||
| 504 | description: Get score logs of every player. | ||
| 505 | produces: | ||
| 506 | - application/json | ||
| 507 | responses: | ||
| 508 | "200": | ||
| 509 | description: OK | ||
| 510 | schema: | ||
| 511 | allOf: | ||
| 512 | - $ref: '#/definitions/models.Response' | ||
| 513 | - properties: | ||
| 514 | data: | ||
| 515 | $ref: '#/definitions/handlers.ScoreLogsResponse' | ||
| 516 | type: object | ||
| 517 | "400": | ||
| 518 | description: Bad Request | ||
| 519 | schema: | ||
| 520 | $ref: '#/definitions/models.Response' | ||
| 521 | tags: | ||
| 522 | - rankings | ||
| 447 | /maps/{id}/image: | 523 | /maps/{id}/image: |
| 448 | put: | 524 | put: |
| 449 | description: Edit map image with specified map id. | 525 | description: Edit map image with specified map id. |