add reviews

This commit is contained in:
2026-09-18 01:37:48 +07:00
parent 6c8f1fb9e1
commit e9e35c60d5
15 changed files with 2278 additions and 551 deletions
+8
View File
@@ -15,6 +15,7 @@ import (
"evening_detective_server/internal/repos/actions_repo"
"evening_detective_server/internal/repos/applications_repo"
"evening_detective_server/internal/repos/game_map_repo"
"evening_detective_server/internal/repos/game_reviews_repo"
"evening_detective_server/internal/repos/games_repo"
"evening_detective_server/internal/repos/refresh_tokens_repo"
"evening_detective_server/internal/repos/scenarios_repo"
@@ -24,6 +25,7 @@ import (
"evening_detective_server/internal/repos/users_repo"
"evening_detective_server/internal/services/answer_service"
"evening_detective_server/internal/services/file_service"
"evening_detective_server/internal/services/game_review_service"
"evening_detective_server/internal/services/game_service"
"evening_detective_server/internal/services/gameplay_service"
"evening_detective_server/internal/services/mcp_service"
@@ -134,6 +136,7 @@ func main() {
answersRepo := team_answers_repo.NewTeamAnswersRepo(dbpool)
screenRepo := screen_sessions_repo.NewScreenSessionsRepo(dbpool)
mapRepo := game_map_repo.New(dbpool)
reviewsRepo := game_reviews_repo.New(dbpool)
gameService := game_service.NewGameService(
gameRepo,
teamRepo,
@@ -147,11 +150,13 @@ func main() {
gameplayService := gameplay_service.NewGameplayService(gameRepo, teamRepo, scenarioService, storyteller, actionsRepo, applicationsRepo, cleaner, os.Getenv("FILE_PREFIX_DOMAIN"))
answerService := answer_service.NewAnswerService(gameRepo, teamRepo, scenarioService, answersRepo, actionsRepo)
reviewService := game_review_service.New(reviewsRepo, gameRepo, teamRepo, os.Getenv("APP_BASE_URL"))
teamService := team_service.NewTeamService(gameRepo, teamRepo, passwordGenerator, os.Getenv("APP_BASE_URL"), emailSender)
participationService := participation_service.NewParticipationService(teamRepo, os.Getenv("APP_BASE_URL"))
go participationService.RunParticipationEmails(context.Background(), emailSender, os.Getenv("PARTICIPATION_SECRET"), os.Getenv("GAME_TIMEZONE"))
go reviewService.RunReviewReminderEmails(context.Background(), emailSender)
// Create a listener on TCP port
lis, err := net.Listen("tcp", ":8080")
@@ -186,6 +191,8 @@ func main() {
"/crabs.evening_detective_server.EveningDetectiveServer/CreateScreenSession": true,
"/crabs.evening_detective_server.EveningDetectiveServer/GetScreenState": true,
"/crabs.evening_detective_server.EveningDetectiveServer/GetScreenResults": true,
"/crabs.evening_detective_server.EveningDetectiveServer/CreateGameReview": true,
"/crabs.evening_detective_server.EveningDetectiveServer/GetGameReviews": true,
},
processorJWT,
),
@@ -202,6 +209,7 @@ func main() {
gameService,
gameplayService,
answerService,
reviewService,
teamService,
participationService,
screenRepo,
@@ -16,6 +16,78 @@
"application/json"
],
"paths": {
"/api/admin/game-reviews/{id}": {
"put": {
"summary": "Модерировать отзыв",
"operationId": "EveningDetectiveServer_ModerateGameReview",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/evening_detective_serverModerateGameReviewRsp"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "integer",
"format": "int32"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/EveningDetectiveServerModerateGameReviewBody"
}
}
],
"tags": [
"Отзывы"
]
}
},
"/api/admin/games/{gameId}/reviews": {
"get": {
"summary": "Получить отзывы игры для модерации",
"operationId": "EveningDetectiveServer_GetGameReviewsForModeration",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/evening_detective_serverGetGameReviewsRsp"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "gameId",
"in": "path",
"required": true,
"type": "integer",
"format": "int32"
}
],
"tags": [
"Отзывы"
]
}
},
"/api/auth/delete-account": {
"delete": {
"summary": "Удалить учётную запись и персональные данные",
@@ -505,6 +577,86 @@
]
}
},
"/api/games/{gameId}/reviews": {
"get": {
"summary": "Получить отзывы об игре",
"operationId": "EveningDetectiveServer_GetGameReviews",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/evening_detective_serverGetGameReviewsRsp"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "gameId",
"in": "path",
"required": true,
"type": "integer",
"format": "int32"
}
],
"tags": [
"Отзывы"
],
"security": [
{
"": []
}
]
},
"post": {
"summary": "Оставить отзыв об игре",
"operationId": "EveningDetectiveServer_CreateGameReview",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/evening_detective_serverCreateGameReviewRsp"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "gameId",
"in": "path",
"required": true,
"type": "integer",
"format": "int32"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/EveningDetectiveServerCreateGameReviewBody"
}
}
],
"tags": [
"Отзывы"
],
"security": [
{
"": []
}
]
}
},
"/api/games/{gameId}/screens": {
"get": {
"summary": "Получить экраны игры",
@@ -2727,6 +2879,25 @@
}
}
},
"EveningDetectiveServerCreateGameReviewBody": {
"type": "object",
"properties": {
"teamId": {
"type": "integer",
"format": "int32"
},
"password": {
"type": "string"
},
"rating": {
"type": "integer",
"format": "int32"
},
"text": {
"type": "string"
}
}
},
"EveningDetectiveServerDeleteUserRoleBody": {
"type": "object",
"properties": {
@@ -2749,6 +2920,14 @@
}
}
},
"EveningDetectiveServerModerateGameReviewBody": {
"type": "object",
"properties": {
"status": {
"type": "string"
}
}
},
"EveningDetectiveServerPauseGameBody": {
"type": "object"
},
@@ -3147,6 +3326,17 @@
}
}
},
"evening_detective_serverCreateGameReviewRsp": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"review": {
"$ref": "#/definitions/evening_detective_serverGameReview"
}
}
},
"evening_detective_serverCreateScreenSessionReq": {
"type": "object"
},
@@ -3313,6 +3503,40 @@
}
}
},
"evening_detective_serverGameReview": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int32"
},
"gameId": {
"type": "integer",
"format": "int32"
},
"teamId": {
"type": "integer",
"format": "int32"
},
"teamName": {
"type": "string"
},
"rating": {
"type": "integer",
"format": "int32"
},
"text": {
"type": "string"
},
"status": {
"type": "string"
},
"createdAt": {
"type": "string",
"format": "date-time"
}
}
},
"evening_detective_serverGetConsentRsp": {
"type": "object",
"properties": {
@@ -3383,6 +3607,29 @@
}
}
},
"evening_detective_serverGetGameReviewsRsp": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"averageRating": {
"type": "number",
"format": "double"
},
"reviewsCount": {
"type": "integer",
"format": "int32"
},
"reviews": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/evening_detective_serverGameReview"
}
}
}
},
"evening_detective_serverGetGameRsp": {
"type": "object",
"properties": {
@@ -3722,6 +3969,17 @@
}
}
},
"evening_detective_serverModerateGameReviewRsp": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"review": {
"$ref": "#/definitions/evening_detective_serverGameReview"
}
}
},
"evening_detective_serverParticipationRsp": {
"type": "object",
"properties": {