Skip to content

Commit

Permalink
feat: Add penalty endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
BasedDepartment1 committed Apr 21, 2024
1 parent 37d4bed commit 3215646
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 86 deletions.
1 change: 1 addition & 0 deletions src/cmd/questspace/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func Init(app application.App) error {
questGroup.POST("/:id/answer", jwt.AuthMiddlewareStrict(jwtParser), application.AsGinHandler(playHandler.HandleTryAnswer))
questGroup.GET("/:id/table", jwt.AuthMiddlewareStrict(jwtParser), application.AsGinHandler(playHandler.HandleGetTableResults))
questGroup.GET("/:id/leaderboard", application.AsGinHandler(playHandler.HandleLeaderboard))
questGroup.POST("/:id/penalty", jwt.AuthMiddlewareStrict(jwtParser), application.AsGinHandler(playHandler.HandleAddPenalty))

app.Router().GET("/swagger/*any", ginswagger.WrapHandler(swaggerfiles.Handler))
return nil
Expand Down
106 changes: 74 additions & 32 deletions src/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,54 @@ const docTemplate = `{
}
}
},
"/quest/{id}/penalty": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"tags": [
"PlayMode"
],
"summary": "Add penalty to team",
"parameters": [
{
"type": "string",
"description": "Quest ID",
"name": "quest_id",
"in": "path",
"required": true
},
{
"description": "Data to set penalty",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/game.AddPenaltyRequest"
}
}
],
"responses": {
"200": {
"description": "OK"
},
"400": {
"description": "Bad Request"
},
"401": {
"description": "Unauthorized"
},
"404": {
"description": "Not Found"
},
"406": {
"description": "Not Acceptable"
}
}
}
},
"/quest/{id}/play": {
"get": {
"security": [
Expand Down Expand Up @@ -1251,6 +1299,17 @@ const docTemplate = `{
}
}
},
"game.AddPenaltyRequest": {
"type": "object",
"properties": {
"penalty": {
"type": "integer"
},
"team_id": {
"type": "string"
}
}
},
"game.AnswerDataResponse": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1376,32 +1435,9 @@ const docTemplate = `{
}
}
},
"game.TaskGroupResult": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"tasks": {
"type": "array",
"items": {
"$ref": "#/definitions/game.TaskResult"
}
}
}
},
"game.TaskResult": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"score": {
"type": "integer"
}
Expand All @@ -1410,22 +1446,22 @@ const docTemplate = `{
"game.TeamResult": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"penalty": {
"type": "integer"
},
"task_groups": {
"taskResults": {
"type": "array",
"items": {
"$ref": "#/definitions/game.TaskGroupResult"
"$ref": "#/definitions/game.TaskResult"
}
},
"total_score": {
"teamID": {
"type": "string"
},
"teamName": {
"type": "string"
},
"totalScore": {
"type": "integer"
}
}
Expand All @@ -1438,6 +1474,12 @@ const docTemplate = `{
"items": {
"$ref": "#/definitions/game.TeamResult"
}
},
"task_groups": {
"type": "array",
"items": {
"$ref": "#/definitions/storage.TaskGroup"
}
}
}
},
Expand Down
106 changes: 74 additions & 32 deletions src/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,54 @@
}
}
},
"/quest/{id}/penalty": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"tags": [
"PlayMode"
],
"summary": "Add penalty to team",
"parameters": [
{
"type": "string",
"description": "Quest ID",
"name": "quest_id",
"in": "path",
"required": true
},
{
"description": "Data to set penalty",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/game.AddPenaltyRequest"
}
}
],
"responses": {
"200": {
"description": "OK"
},
"400": {
"description": "Bad Request"
},
"401": {
"description": "Unauthorized"
},
"404": {
"description": "Not Found"
},
"406": {
"description": "Not Acceptable"
}
}
}
},
"/quest/{id}/play": {
"get": {
"security": [
Expand Down Expand Up @@ -1240,6 +1288,17 @@
}
}
},
"game.AddPenaltyRequest": {
"type": "object",
"properties": {
"penalty": {
"type": "integer"
},
"team_id": {
"type": "string"
}
}
},
"game.AnswerDataResponse": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1365,32 +1424,9 @@
}
}
},
"game.TaskGroupResult": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"tasks": {
"type": "array",
"items": {
"$ref": "#/definitions/game.TaskResult"
}
}
}
},
"game.TaskResult": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"score": {
"type": "integer"
}
Expand All @@ -1399,22 +1435,22 @@
"game.TeamResult": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"penalty": {
"type": "integer"
},
"task_groups": {
"taskResults": {
"type": "array",
"items": {
"$ref": "#/definitions/game.TaskGroupResult"
"$ref": "#/definitions/game.TaskResult"
}
},
"total_score": {
"teamID": {
"type": "string"
},
"teamName": {
"type": "string"
},
"totalScore": {
"type": "integer"
}
}
Expand All @@ -1427,6 +1463,12 @@
"items": {
"$ref": "#/definitions/game.TeamResult"
}
},
"task_groups": {
"type": "array",
"items": {
"$ref": "#/definitions/storage.TaskGroup"
}
}
}
},
Expand Down
Loading

0 comments on commit 3215646

Please sign in to comment.