From 6fc19833d3aa524f6ed5089d9b8f5199ab083c28 Mon Sep 17 00:00:00 2001 From: Fedorov Vladimir Date: Sun, 26 Jul 2026 22:38:33 +0700 Subject: [PATCH] add games operations --- api/main.proto | 117 ++- cmd/evening_detective_server/main.go | 12 + .../main.swagger.json | 290 ++++++ internal/app/game_mapper.go | 32 + internal/app/server.go | 119 ++- internal/app/story_mapper.go | 3 + internal/app/team_mapper.go | 25 + .../modules/password_generator/generator.go | 1 + internal/repos/game.go | 16 + internal/repos/games_repo/repo.go | 179 ++++ internal/repos/scenarios_repo/repo.go | 36 +- internal/repos/team.go | 7 + internal/repos/teams_repo/repo.go | 67 ++ internal/services/game_service/game.go | 16 + internal/services/game_service/game_mapper.go | 32 + internal/services/game_service/service.go | 93 ++ internal/services/game_service/team.go | 7 + internal/services/game_service/team_mapper.go | 23 + .../scenarios_service/scenario_mapper.go | 9 +- .../services/scenarios_service/service.go | 2 +- .../20260725140814_crerate_games_table.sql | 5 +- proto/main.pb.go | 879 ++++++++++++++++-- proto/main.pb.gw.go | 366 ++++++++ proto/main_grpc.pb.go | 190 ++++ 24 files changed, 2430 insertions(+), 96 deletions(-) create mode 100644 internal/app/game_mapper.go create mode 100644 internal/app/team_mapper.go create mode 100644 internal/repos/game.go create mode 100644 internal/repos/games_repo/repo.go create mode 100644 internal/repos/team.go create mode 100644 internal/repos/teams_repo/repo.go create mode 100644 internal/services/game_service/game.go create mode 100644 internal/services/game_service/game_mapper.go create mode 100644 internal/services/game_service/service.go create mode 100644 internal/services/game_service/team.go create mode 100644 internal/services/game_service/team_mapper.go diff --git a/api/main.proto b/api/main.proto index d282dff..fbcc114 100644 --- a/api/main.proto +++ b/api/main.proto @@ -323,6 +323,58 @@ service EveningDetectiveServer { summary: "Удалить точку сценария"; }; } + + rpc AddGame(AddGameReq) returns (AddGameRsp) { + option (google.api.http) = { + post: "/api/games" + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags : "Игры"; + summary: "Создать игру"; + }; + } + + rpc GetGames(GetGamesReq) returns (GetGamesRsp) { + option (google.api.http) = { + get: "/api/games" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags : "Игры"; + summary: "Получить игры"; + }; + } + + rpc GetGame(GetGameReq) returns (GetGameRsp) { + option (google.api.http) = { + get: "/api/games/{id}" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags : "Игры"; + summary: "Получить игру"; + }; + } + + rpc UpdateGame(UpdateGameReq) returns (UpdateGameRsp) { + option (google.api.http) = { + put : "/api/games/{id}" + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags : "Игры"; + summary: "Обновить игру"; + }; + } + + rpc DeleteGame(DeleteGameReq) returns (DeleteGameRsp) { + option (google.api.http) = { + delete: "/api/games/{id}" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags : "Игры"; + summary: "Удалить игру"; + }; + } } message PingReq {} @@ -582,4 +634,67 @@ message DeleteScenarioPlaceReq { message DeleteScenarioPlaceRsp { string error = 1; -} \ No newline at end of file +} + +message AddGameReq { + string name = 1; + string description = 2; + google.protobuf.Timestamp start_at = 3; + int32 scenario_id = 4; +} + +message AddGameRsp { + string error = 1; + int32 id = 2; +} + +message GetGamesReq {} + +message GetGamesRsp { + string error = 1; + repeated Game games = 2; +} + +message Game { + int32 id = 1; + string name = 2; + string description = 3; + google.protobuf.Timestamp start_at = 4; + string status = 5; + Scenario scenario = 6; + repeated Team teams = 7; +} + +message Team { + int32 id = 1; + string name = 2; +} + +message GetGameReq { + int32 id = 1; +} + +message GetGameRsp { + string error = 1; + Game game = 2; +} + +message UpdateGameReq { + int32 id = 1; + string name = 2; + string description = 3; + google.protobuf.Timestamp start_at = 4; + int32 scenario_id = 5; +} + +message UpdateGameRsp { + string error = 1; +} + +message DeleteGameReq { + int32 id = 1; +} + +message DeleteGameRsp { + string error = 1; +} diff --git a/cmd/evening_detective_server/main.go b/cmd/evening_detective_server/main.go index 02c99a6..8317c80 100644 --- a/cmd/evening_detective_server/main.go +++ b/cmd/evening_detective_server/main.go @@ -8,10 +8,13 @@ import ( "evening_detective_server/internal/modules/file_storage" "evening_detective_server/internal/modules/password_generator" "evening_detective_server/internal/modules/processor_jwt" + "evening_detective_server/internal/repos/games_repo" "evening_detective_server/internal/repos/refresh_tokens_repo" "evening_detective_server/internal/repos/scenarios_repo" + "evening_detective_server/internal/repos/teams_repo" "evening_detective_server/internal/repos/users_repo" "evening_detective_server/internal/services/file_service" + "evening_detective_server/internal/services/game_service" "evening_detective_server/internal/services/scenarios_service" "evening_detective_server/internal/services/ui_service" "evening_detective_server/internal/services/users_service" @@ -76,6 +79,14 @@ func main() { scenariosRepo, os.Getenv("FILE_PREFIX_DOMAIN"), ) + gameRepo := games_repo.NewGamesRepo(dbpool) + teamRepo := teams_repo.NewTeamsRepo(dbpool) + gameService := game_service.NewGameService( + gameRepo, + teamRepo, + scenariosRepo, + os.Getenv("FILE_PREFIX_DOMAIN"), + ) // Create a listener on TCP port lis, err := net.Listen("tcp", ":8080") @@ -110,6 +121,7 @@ func main() { uiService, fileService, scenarioService, + gameService, ), ) diff --git a/cmd/evening_detective_server/main.swagger.json b/cmd/evening_detective_server/main.swagger.json index fc4652d..9c2ee07 100644 --- a/cmd/evening_detective_server/main.swagger.json +++ b/cmd/evening_detective_server/main.swagger.json @@ -255,6 +255,160 @@ ] } }, + "/api/games": { + "get": { + "summary": "Получить игры", + "operationId": "EveningDetectiveServer_GetGames", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/evening_detective_serverGetGamesRsp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "tags": [ + "Игры" + ] + }, + "post": { + "summary": "Создать игру", + "operationId": "EveningDetectiveServer_AddGame", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/evening_detective_serverAddGameRsp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/evening_detective_serverAddGameReq" + } + } + ], + "tags": [ + "Игры" + ] + } + }, + "/api/games/{id}": { + "get": { + "summary": "Получить игру", + "operationId": "EveningDetectiveServer_GetGame", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/evening_detective_serverGetGameRsp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "type": "integer", + "format": "int32" + } + ], + "tags": [ + "Игры" + ] + }, + "delete": { + "summary": "Удалить игру", + "operationId": "EveningDetectiveServer_DeleteGame", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/evening_detective_serverDeleteGameRsp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "type": "integer", + "format": "int32" + } + ], + "tags": [ + "Игры" + ] + }, + "put": { + "summary": "Обновить игру", + "operationId": "EveningDetectiveServer_UpdateGame", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/evening_detective_serverUpdateGameRsp" + } + }, + "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/EveningDetectiveServerUpdateGameBody" + } + } + ], + "tags": [ + "Игры" + ] + } + }, "/api/my-scenarios": { "get": { "summary": "Получить свои сценарии", @@ -922,6 +1076,25 @@ "EveningDetectiveServerPublicScenarioBody": { "type": "object" }, + "EveningDetectiveServerUpdateGameBody": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "startAt": { + "type": "string", + "format": "date-time" + }, + "scenarioId": { + "type": "integer", + "format": "int32" + } + } + }, "EveningDetectiveServerUpdateScenarioBody": { "type": "object", "properties": { @@ -967,6 +1140,37 @@ }, "description": "Message that represents an arbitrary HTTP body. It should only be used for\npayload formats that can't be represented as JSON, such as raw binary or\nan HTML page.\n\n\nThis message can be used both in streaming and non-streaming API methods in\nthe request as well as the response.\n\nIt can be used as a top-level request field, which is convenient if one\nwants to extract parameters from either the URL or HTTP template into the\nrequest fields and also want access to the raw HTTP body.\n\nExample:\n\n message GetResourceRequest {\n // A unique request id.\n string request_id = 1;\n\n // The raw HTTP body is bound to this field.\n google.api.HttpBody http_body = 2;\n\n }\n\n service ResourceService {\n rpc GetResource(GetResourceRequest)\n returns (google.api.HttpBody);\n rpc UpdateResource(google.api.HttpBody)\n returns (google.protobuf.Empty);\n\n }\n\nExample with streaming methods:\n\n service CaldavService {\n rpc GetCalendar(stream google.api.HttpBody)\n returns (stream google.api.HttpBody);\n rpc UpdateCalendar(stream google.api.HttpBody)\n returns (stream google.api.HttpBody);\n\n }\n\nUse of this type only changes how the request and response bodies are\nhandled, all other features will continue to work unchanged." }, + "evening_detective_serverAddGameReq": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "startAt": { + "type": "string", + "format": "date-time" + }, + "scenarioId": { + "type": "integer", + "format": "int32" + } + } + }, + "evening_detective_serverAddGameRsp": { + "type": "object", + "properties": { + "error": { + "type": "string" + }, + "id": { + "type": "integer", + "format": "int32" + } + } + }, "evening_detective_serverAddScenarioPlaceRsp": { "type": "object", "properties": { @@ -1014,6 +1218,14 @@ } } }, + "evening_detective_serverDeleteGameRsp": { + "type": "object", + "properties": { + "error": { + "type": "string" + } + } + }, "evening_detective_serverDeleteScenarioPlaceRsp": { "type": "object", "properties": { @@ -1072,6 +1284,64 @@ } } }, + "evening_detective_serverGame": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "startAt": { + "type": "string", + "format": "date-time" + }, + "status": { + "type": "string" + }, + "scenario": { + "$ref": "#/definitions/evening_detective_serverScenario" + }, + "teams": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/evening_detective_serverTeam" + } + } + } + }, + "evening_detective_serverGetGameRsp": { + "type": "object", + "properties": { + "error": { + "type": "string" + }, + "game": { + "$ref": "#/definitions/evening_detective_serverGame" + } + } + }, + "evening_detective_serverGetGamesRsp": { + "type": "object", + "properties": { + "error": { + "type": "string" + }, + "games": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/evening_detective_serverGame" + } + } + } + }, "evening_detective_serverGetMeRsp": { "type": "object", "properties": { @@ -1357,6 +1627,26 @@ } } }, + "evening_detective_serverTeam": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "name": { + "type": "string" + } + } + }, + "evening_detective_serverUpdateGameRsp": { + "type": "object", + "properties": { + "error": { + "type": "string" + } + } + }, "evening_detective_serverUpdateScenarioPlaceRsp": { "type": "object", "properties": { diff --git a/internal/app/game_mapper.go b/internal/app/game_mapper.go new file mode 100644 index 0000000..43e619b --- /dev/null +++ b/internal/app/game_mapper.go @@ -0,0 +1,32 @@ +package app + +import ( + "evening_detective_server/internal/services/game_service" + "evening_detective_server/proto" + + "google.golang.org/protobuf/types/known/timestamppb" +) + +func mapGame( + o *game_service.Game, +) *proto.Game { + return &proto.Game{ + Id: int32(o.ID), + Name: o.Name, + Description: o.Description, + StartAt: timestamppb.New(o.StartAt), + Status: o.Status, + Scenario: mapScenario(o.Scenario), + Teams: mapTeams(o.Teams), + } +} + +func mapGames( + o []*game_service.Game, +) []*proto.Game { + res := make([]*proto.Game, 0, len(o)) + for _, item := range o { + res = append(res, mapGame(item)) + } + return res +} diff --git a/internal/app/server.go b/internal/app/server.go index 3db4dd4..1a627d8 100644 --- a/internal/app/server.go +++ b/internal/app/server.go @@ -6,6 +6,7 @@ import ( "evening_detective_server/internal/modules/processor_jwt" "evening_detective_server/internal/modules/roles" "evening_detective_server/internal/services/file_service" + "evening_detective_server/internal/services/game_service" "evening_detective_server/internal/services/scenarios_service" "evening_detective_server/internal/services/ui_service" "evening_detective_server/internal/services/users_service" @@ -23,6 +24,7 @@ type server struct { uiService *ui_service.UiService fileService *file_service.FileService scenarioService *scenarios_service.ScenarioService + gameService *game_service.GameService } func NewServer( @@ -30,12 +32,14 @@ func NewServer( uiService *ui_service.UiService, fileService *file_service.FileService, scenarioService *scenarios_service.ScenarioService, + gameService *game_service.GameService, ) proto.EveningDetectiveServerServer { return &server{ usersService: usersService, uiService: uiService, fileService: fileService, scenarioService: scenarioService, + gameService: gameService, } } @@ -167,10 +171,7 @@ func (s *server) DeleteUserRole(ctx context.Context, req *proto.DeleteUserRoleRe return &proto.DeleteUserRoleRsp{}, nil } -func (s *server) GetPermissions( - ctx context.Context, - req *proto.GetPermissionsReq, -) (*proto.GetPermissionsRsp, error) { +func (s *server) GetPermissions(ctx context.Context, req *proto.GetPermissionsReq) (*proto.GetPermissionsRsp, error) { claims := ctx.Value("claims").(*processor_jwt.JWTClaims) permissions := s.uiService.GetPermissions(claims.Roles) return &proto.GetPermissionsRsp{ @@ -427,3 +428,113 @@ func (s *server) DeleteScenarioPlace(ctx context.Context, req *proto.DeleteScena return &proto.DeleteScenarioPlaceRsp{}, nil } + +func (s *server) AddGame(ctx context.Context, req *proto.AddGameReq) (*proto.AddGameRsp, error) { + claims := ctx.Value("claims").(*processor_jwt.JWTClaims) + if !roles.HasRole(claims, roles.Organizer) { + return nil, status.Errorf(codes.PermissionDenied, "permission denied") + } + + if req.StartAt == nil { + return nil, status.Errorf(codes.InvalidArgument, "startAt must not be nil") + } + + id, err := s.gameService.AddGame( + ctx, + req.Name, + req.Description, + req.StartAt.AsTime(), + req.ScenarioId, + ) + if err != nil { + return &proto.AddGameRsp{ + Error: err.Error(), + }, nil + } + + return &proto.AddGameRsp{ + Id: int32(id), + }, nil +} + +func (s *server) DeleteGame(ctx context.Context, req *proto.DeleteGameReq) (*proto.DeleteGameRsp, error) { + claims := ctx.Value("claims").(*processor_jwt.JWTClaims) + if !roles.HasRole(claims, roles.Organizer) { + return nil, status.Errorf(codes.PermissionDenied, "permission denied") + } + + err := s.gameService.DeleteGame( + ctx, + int(req.Id), + ) + if err != nil { + return &proto.DeleteGameRsp{ + Error: err.Error(), + }, nil + } + + return &proto.DeleteGameRsp{}, nil +} + +func (s *server) GetGame(ctx context.Context, req *proto.GetGameReq) (*proto.GetGameRsp, error) { + claims := ctx.Value("claims").(*processor_jwt.JWTClaims) + if !roles.HasRole(claims, roles.Organizer) { + return nil, status.Errorf(codes.PermissionDenied, "permission denied") + } + + game, err := s.gameService.GetGame(ctx, int(req.Id)) + if err != nil { + return &proto.GetGameRsp{ + Error: err.Error(), + }, nil + } + + return &proto.GetGameRsp{ + Game: mapGame(game), + }, nil +} + +func (s *server) GetGames(ctx context.Context, req *proto.GetGamesReq) (*proto.GetGamesRsp, error) { + claims := ctx.Value("claims").(*processor_jwt.JWTClaims) + if !roles.HasRole(claims, roles.Organizer) { + return nil, status.Errorf(codes.PermissionDenied, "permission denied") + } + + games, err := s.gameService.GetGames(ctx) + if err != nil { + return &proto.GetGamesRsp{ + Error: err.Error(), + }, nil + } + + return &proto.GetGamesRsp{ + Games: mapGames(games), + }, nil +} + +func (s *server) UpdateGame(ctx context.Context, req *proto.UpdateGameReq) (*proto.UpdateGameRsp, error) { + claims := ctx.Value("claims").(*processor_jwt.JWTClaims) + if !roles.HasRole(claims, roles.Organizer) { + return nil, status.Errorf(codes.PermissionDenied, "permission denied") + } + + if req.StartAt == nil { + return nil, status.Errorf(codes.InvalidArgument, "startAt must not be nil") + } + + err := s.gameService.UpdateGame( + ctx, + int(req.Id), + req.Name, + req.Description, + req.StartAt.AsTime(), + req.ScenarioId, + ) + if err != nil { + return &proto.UpdateGameRsp{ + Error: err.Error(), + }, nil + } + + return &proto.UpdateGameRsp{}, nil +} diff --git a/internal/app/story_mapper.go b/internal/app/story_mapper.go index 67a4c65..0b9b7a5 100644 --- a/internal/app/story_mapper.go +++ b/internal/app/story_mapper.go @@ -18,6 +18,9 @@ func mapScenarios(o []*scenarios_service.Scenario) []*proto.Scenario { } func mapScenario(o *scenarios_service.Scenario) *proto.Scenario { + if o == nil { + return nil + } var publishedAt *timestamppb.Timestamp if o.PublishedAt != nil { publishedAt = timestamppb.New(*o.PublishedAt) diff --git a/internal/app/team_mapper.go b/internal/app/team_mapper.go new file mode 100644 index 0000000..00295ec --- /dev/null +++ b/internal/app/team_mapper.go @@ -0,0 +1,25 @@ +package app + +import ( + "evening_detective_server/internal/services/game_service" + "evening_detective_server/proto" +) + +func mapTeam( + o *game_service.Team, +) *proto.Team { + return &proto.Team{ + Id: int32(o.ID), + Name: o.Name, + } +} + +func mapTeams( + o []*game_service.Team, +) []*proto.Team { + res := make([]*proto.Team, 0, len(o)) + for _, item := range o { + res = append(res, mapTeam(item)) + } + return res +} diff --git a/internal/modules/password_generator/generator.go b/internal/modules/password_generator/generator.go index 18ce9b1..a9c9b7d 100644 --- a/internal/modules/password_generator/generator.go +++ b/internal/modules/password_generator/generator.go @@ -20,6 +20,7 @@ func NewGenerator(length int) IPasswordGenerator { } func (g *generator) Generate() (string, error) { + return "1", nil password := make([]byte, g.length) for i := range password { num, err := rand.Int(rand.Reader, big.NewInt(int64(len(charset)))) diff --git a/internal/repos/game.go b/internal/repos/game.go new file mode 100644 index 0000000..d21892f --- /dev/null +++ b/internal/repos/game.go @@ -0,0 +1,16 @@ +package repos + +import ( + "time" +) + +type Game struct { + ID int + Name string + Description string + StartAt time.Time + Status string + ScenarioId int + Scenario *Scenario + Teams []*Team +} diff --git a/internal/repos/games_repo/repo.go b/internal/repos/games_repo/repo.go new file mode 100644 index 0000000..194b004 --- /dev/null +++ b/internal/repos/games_repo/repo.go @@ -0,0 +1,179 @@ +package games_repo + +import ( + "context" + "errors" + "evening_detective_server/internal/repos" + "time" + + "github.com/jackc/pgx/v5" + "github.com/jackc/pgx/v5/pgxpool" +) + +var ( + ErrGameNotFound = errors.New("Игра не найдена") +) + +type GamesRepo struct { + pool *pgxpool.Pool +} + +func NewGamesRepo(pool *pgxpool.Pool) *GamesRepo { + return &GamesRepo{ + pool: pool, + } +} + +func (r *GamesRepo) AddGame( + ctx context.Context, + name string, + description string, + startAt time.Time, + scenarioId int32, +) (int, error) { + id := 0 + err := r.pool.QueryRow( + ctx, + `INSERT INTO games (name, description, start_at, scenario_id) + VALUES ($1, $2, $3, $4) + RETURNING id`, + name, + description, + startAt, + scenarioId, + ).Scan(&id) + + if err != nil { + return 0, err + } + return id, nil +} + +func (r *GamesRepo) GetGameByID( + ctx context.Context, + id int, +) (*repos.Game, error) { + game := &repos.Game{} + row := r.pool.QueryRow( + ctx, + `SELECT + games.id, + games.name, + games.description, + games.start_at, + games.status, + games.scenario_id + FROM games + WHERE id = $1`, + id, + ) + err := row.Scan( + &game.ID, + &game.Name, + &game.Description, + &game.StartAt, + &game.Status, + &game.ScenarioId, + ) + if err != nil { + if errors.Is(err, pgx.ErrNoRows) { + return nil, ErrGameNotFound + } + return nil, err + } + + return game, nil +} + +func (r *GamesRepo) DeleteGameByID( + ctx context.Context, + id int, +) error { + tag, err := r.pool.Exec( + ctx, + `DELETE FROM games + WHERE id = $1`, + id, + ) + if err != nil { + return err + } + if tag.RowsAffected() == 0 { + return ErrGameNotFound + } + return nil +} + +func (r *GamesRepo) GetGames( + ctx context.Context, +) ([]*repos.Game, error) { + rows, err := r.pool.Query( + ctx, + `SELECT + games.id, + games.name, + games.description, + games.start_at, + games.status + FROM games + ORDER BY created_at DESC`, + ) + if err != nil { + return nil, err + } + defer rows.Close() + + var games []*repos.Game + for rows.Next() { + game := &repos.Game{} + err := rows.Scan( + &game.ID, + &game.Name, + &game.Description, + &game.StartAt, + &game.Status, + ) + if err != nil { + return nil, err + } + games = append(games, game) + } + if err := rows.Err(); err != nil { + return nil, err + } + + return games, nil +} + +func (r *GamesRepo) UpdateGame( + ctx context.Context, + id int, + name string, + description string, + startAt time.Time, + scenarioId int32, +) error { + tag, err := r.pool.Exec( + ctx, + `UPDATE games + SET + name = $1, + description = $2, + start_at = $3, + scenario_id = $4, + updated_at = NOW() + WHERE id = $5`, + name, + description, + startAt, + scenarioId, + id, + ) + if err != nil { + return err + } + if tag.RowsAffected() == 0 { + return ErrGameNotFound + } + return nil +} diff --git a/internal/repos/scenarios_repo/repo.go b/internal/repos/scenarios_repo/repo.go index fcb1a11..639b468 100644 --- a/internal/repos/scenarios_repo/repo.go +++ b/internal/repos/scenarios_repo/repo.go @@ -23,13 +23,13 @@ func NewScenariosRepo(pool *pgxpool.Pool) *ScenariosRepo { } } -func (s *ScenariosRepo) AddScenario( +func (r *ScenariosRepo) AddScenario( ctx context.Context, name string, authorId int, ) (int, error) { id := 0 - err := s.pool.QueryRow( + err := r.pool.QueryRow( ctx, `INSERT INTO scenarios (name, author_id) VALUES ($1, $2) @@ -44,11 +44,11 @@ func (s *ScenariosRepo) AddScenario( return id, nil } -func (s *ScenariosRepo) GetScenariosByAuthorID( +func (r *ScenariosRepo) GetScenariosByAuthorID( ctx context.Context, authorId int, ) ([]*repos.Scenario, error) { - rows, err := s.pool.Query( + rows, err := r.pool.Query( ctx, `SELECT scenarios.id, @@ -103,11 +103,11 @@ func (s *ScenariosRepo) GetScenariosByAuthorID( return scenarios, nil } -func (s *ScenariosRepo) GetScenariosByStatus( +func (r *ScenariosRepo) GetScenariosByStatus( ctx context.Context, status string, ) ([]*repos.Scenario, error) { - rows, err := s.pool.Query( + rows, err := r.pool.Query( ctx, `SELECT scenarios.id, @@ -162,14 +162,14 @@ func (s *ScenariosRepo) GetScenariosByStatus( return scenarios, nil } -func (s *ScenariosRepo) GetScenarioByID( +func (r *ScenariosRepo) GetScenarioByID( ctx context.Context, id int, ) (*repos.Scenario, error) { scenario := &repos.Scenario{ Author: &repos.User{}, } - row := s.pool.QueryRow( + row := r.pool.QueryRow( ctx, `SELECT scenarios.id, @@ -213,14 +213,14 @@ func (s *ScenariosRepo) GetScenarioByID( return scenario, nil } -func (s *ScenariosRepo) UpdateScenarioByID( +func (r *ScenariosRepo) UpdateScenarioByID( ctx context.Context, id int, name string, description string, image string, ) error { - tag, err := s.pool.Exec( + tag, err := r.pool.Exec( ctx, `UPDATE scenarios SET @@ -243,12 +243,12 @@ func (s *ScenariosRepo) UpdateScenarioByID( return nil } -func (s *ScenariosRepo) UpdateScenarioStatusByID( +func (r *ScenariosRepo) UpdateScenarioStatusByID( ctx context.Context, id int, status string, ) error { - tag, err := s.pool.Exec( + tag, err := r.pool.Exec( ctx, `UPDATE scenarios SET @@ -268,11 +268,11 @@ func (s *ScenariosRepo) UpdateScenarioStatusByID( return nil } -func (s *ScenariosRepo) DeleteScenarioByID( +func (r *ScenariosRepo) DeleteScenarioByID( ctx context.Context, id int, ) error { - tag, err := s.pool.Exec( + tag, err := r.pool.Exec( ctx, `UPDATE scenarios SET @@ -289,12 +289,12 @@ func (s *ScenariosRepo) DeleteScenarioByID( return nil } -func (s *ScenariosRepo) GetStoryByScenarioID( +func (r *ScenariosRepo) GetStoryByScenarioID( ctx context.Context, id int, ) (string, error) { story := "" - row := s.pool.QueryRow( + row := r.pool.QueryRow( ctx, `SELECT scenario @@ -315,12 +315,12 @@ func (s *ScenariosRepo) GetStoryByScenarioID( return story, nil } -func (s *ScenariosRepo) UpdateStoryByScenarioID( +func (r *ScenariosRepo) UpdateStoryByScenarioID( ctx context.Context, id int, story string, ) error { - tag, err := s.pool.Exec( + tag, err := r.pool.Exec( ctx, `UPDATE scenarios SET diff --git a/internal/repos/team.go b/internal/repos/team.go new file mode 100644 index 0000000..8f601b2 --- /dev/null +++ b/internal/repos/team.go @@ -0,0 +1,7 @@ +package repos + +type Team struct { + ID int + Name string + Password string +} diff --git a/internal/repos/teams_repo/repo.go b/internal/repos/teams_repo/repo.go new file mode 100644 index 0000000..c4de284 --- /dev/null +++ b/internal/repos/teams_repo/repo.go @@ -0,0 +1,67 @@ +package teams_repo + +import ( + "context" + "evening_detective_server/internal/repos" + + "github.com/jackc/pgx/v5/pgxpool" +) + +type TeamsRepo struct { + pool *pgxpool.Pool +} + +func NewTeamsRepo(pool *pgxpool.Pool) *TeamsRepo { + return &TeamsRepo{ + pool: pool, + } +} + +func (r *TeamsRepo) GetTeamsByGameID( + ctx context.Context, + gameId int, +) ([]*repos.Team, error) { + rows, err := r.pool.Query( + ctx, + `SELECT + scenarios.id, + scenarios.name, + scenarios.description, + scenarios.image, + scenarios.scenario, + users.id, + users.username, + scenarios.status, + scenarios.updated_at, + scenarios.created_at, + scenarios.published_at + FROM scenarios + LEFT JOIN users on scenarios.author_id = users.id + WHERE scenarios.author_id = $1 and is_deleted = FALSE + ORDER BY created_at DESC`, + gameId, + ) + if err != nil { + return nil, err + } + defer rows.Close() + + var teams []*repos.Team + for rows.Next() { + team := &repos.Team{} + err := rows.Scan( + &team.ID, + &team.Name, + &team.Password, + ) + if err != nil { + return nil, err + } + teams = append(teams, team) + } + if err := rows.Err(); err != nil { + return nil, err + } + + return teams, nil +} diff --git a/internal/services/game_service/game.go b/internal/services/game_service/game.go new file mode 100644 index 0000000..7062675 --- /dev/null +++ b/internal/services/game_service/game.go @@ -0,0 +1,16 @@ +package game_service + +import ( + "evening_detective_server/internal/services/scenarios_service" + "time" +) + +type Game struct { + ID int + Name string + Description string + StartAt time.Time + Status string + Scenario *scenarios_service.Scenario + Teams []*Team +} diff --git a/internal/services/game_service/game_mapper.go b/internal/services/game_service/game_mapper.go new file mode 100644 index 0000000..517bc45 --- /dev/null +++ b/internal/services/game_service/game_mapper.go @@ -0,0 +1,32 @@ +package game_service + +import ( + "evening_detective_server/internal/repos" + "evening_detective_server/internal/services/scenarios_service" +) + +func mapGame( + o *repos.Game, + domain string, +) *Game { + return &Game{ + ID: o.ID, + Name: o.Name, + Description: o.Description, + StartAt: o.StartAt, + Status: o.Status, + Scenario: scenarios_service.MapScenarioLight(o.Scenario, domain), + Teams: mapTeams(o.Teams), + } +} + +func mapGames( + o []*repos.Game, + domain string, +) []*Game { + res := make([]*Game, 0, len(o)) + for _, item := range o { + res = append(res, mapGame(item, domain)) + } + return res +} diff --git a/internal/services/game_service/service.go b/internal/services/game_service/service.go new file mode 100644 index 0000000..45e9cfd --- /dev/null +++ b/internal/services/game_service/service.go @@ -0,0 +1,93 @@ +package game_service + +import ( + "context" + "evening_detective_server/internal/repos/games_repo" + "evening_detective_server/internal/repos/scenarios_repo" + "evening_detective_server/internal/repos/teams_repo" + "time" +) + +type GameService struct { + gamesRepo *games_repo.GamesRepo + teamsRepo *teams_repo.TeamsRepo + scenariosRepo *scenarios_repo.ScenariosRepo + domain string +} + +func NewGameService( + gamesRepo *games_repo.GamesRepo, + teamsRepo *teams_repo.TeamsRepo, + scenariosRepo *scenarios_repo.ScenariosRepo, + domain string, +) *GameService { + return &GameService{ + gamesRepo: gamesRepo, + teamsRepo: teamsRepo, + scenariosRepo: scenariosRepo, + domain: domain, + } +} + +func (s *GameService) AddGame( + ctx context.Context, + name string, + description string, + startAt time.Time, + scenarioId int32, +) (int, error) { + id, err := s.gamesRepo.AddGame(ctx, name, description, startAt, scenarioId) + if err != nil { + return 0, err + } + return id, nil +} + +func (s *GameService) GetGame( + ctx context.Context, + id int, +) (*Game, error) { + game, err := s.gamesRepo.GetGameByID(ctx, id) + if err != nil { + return nil, err + } + scenario, err := s.scenariosRepo.GetScenarioByID(ctx, game.ScenarioId) + if err != nil { + return nil, err + } + game.Scenario = scenario + teams, err := s.teamsRepo.GetTeamsByGameID(ctx, id) + if err != nil { + return nil, err + } + game.Teams = teams + return mapGame(game, s.domain), nil +} + +func (s *GameService) DeleteGame( + ctx context.Context, + id int, +) error { + return s.gamesRepo.DeleteGameByID(ctx, id) +} + +func (s *GameService) GetGames( + ctx context.Context, +) ([]*Game, error) { + games, err := s.gamesRepo.GetGames(ctx) + if err != nil { + return nil, err + } + return mapGames(games, s.domain), nil +} + +func (s *GameService) UpdateGame( + ctx context.Context, + id int, + name string, + description string, + startAt time.Time, + scenarioId int32, +) error { + return s.gamesRepo.UpdateGame(ctx, id, name, description, startAt, scenarioId) +} diff --git a/internal/services/game_service/team.go b/internal/services/game_service/team.go new file mode 100644 index 0000000..da0daed --- /dev/null +++ b/internal/services/game_service/team.go @@ -0,0 +1,7 @@ +package game_service + +type Team struct { + ID int + Name string + Password string +} diff --git a/internal/services/game_service/team_mapper.go b/internal/services/game_service/team_mapper.go new file mode 100644 index 0000000..f97a1ea --- /dev/null +++ b/internal/services/game_service/team_mapper.go @@ -0,0 +1,23 @@ +package game_service + +import "evening_detective_server/internal/repos" + +func mapTeam( + o *repos.Team, +) *Team { + return &Team{ + ID: o.ID, + Name: o.Name, + Password: o.Password, + } +} + +func mapTeams( + o []*repos.Team, +) []*Team { + res := make([]*Team, 0, len(o)) + for _, item := range o { + res = append(res, mapTeam(item)) + } + return res +} diff --git a/internal/services/scenarios_service/scenario_mapper.go b/internal/services/scenarios_service/scenario_mapper.go index db47a6c..22247f5 100644 --- a/internal/services/scenarios_service/scenario_mapper.go +++ b/internal/services/scenarios_service/scenario_mapper.go @@ -12,7 +12,7 @@ func mapScenariosLight( ) []*Scenario { res := make([]*Scenario, 0, len(o)) for _, item := range o { - res = append(res, mapScenarioLight(item, domain)) + res = append(res, MapScenarioLight(item, domain)) } return res } @@ -32,10 +32,13 @@ func mapScenarios( return res, nil } -func mapScenarioLight( +func MapScenarioLight( o *repos.Scenario, domain string, ) *Scenario { + if o == nil { + return nil + } return &Scenario{ ID: o.ID, Name: o.Name, @@ -55,7 +58,7 @@ func mapScenario( o *repos.Scenario, domain string, ) (*Scenario, error) { - scenario := mapScenarioLight(o, domain) + scenario := MapScenarioLight(o, domain) story, err := mapStory(o.Scenario, domain) if err != nil { return nil, err diff --git a/internal/services/scenarios_service/service.go b/internal/services/scenarios_service/service.go index 1461abe..3a46b90 100644 --- a/internal/services/scenarios_service/service.go +++ b/internal/services/scenarios_service/service.go @@ -75,7 +75,7 @@ func (s *ScenarioService) GetScenarioByID( if err != nil { return nil, err } - return mapScenarioLight(scenario, s.domain), nil + return MapScenarioLight(scenario, s.domain), nil } func (s *ScenarioService) UpdateScenarioByID( diff --git a/migrations/20260725140814_crerate_games_table.sql b/migrations/20260725140814_crerate_games_table.sql index 4f92962..1a756a9 100644 --- a/migrations/20260725140814_crerate_games_table.sql +++ b/migrations/20260725140814_crerate_games_table.sql @@ -6,11 +6,12 @@ CREATE TABLE description TEXT, start_at TIMESTAMP NOT NULL, scenario_id INTEGER NOT NULL, - status VARCHAR(50) DEFAULT 'ready', + status VARCHAR(50) DEFAULT 'draft', + updated_at TIMESTAMP NOT NULL DEFAULT NOW (), created_at TIMESTAMP NOT NULL DEFAULT NOW (), started_at TIMESTAMP, ended_at TIMESTAMP, - + CONSTRAINT fk_games_scenario FOREIGN KEY (scenario_id) REFERENCES scenarios (id) ON DELETE RESTRICT ); diff --git a/proto/main.pb.go b/proto/main.pb.go index f7ecd80..23ccc59 100644 --- a/proto/main.pb.go +++ b/proto/main.pb.go @@ -2825,6 +2825,662 @@ func (x *DeleteScenarioPlaceRsp) GetError() string { return "" } +type AddGameReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + StartAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=start_at,json=startAt,proto3" json:"start_at,omitempty"` + ScenarioId int32 `protobuf:"varint,4,opt,name=scenario_id,json=scenarioId,proto3" json:"scenario_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AddGameReq) Reset() { + *x = AddGameReq{} + mi := &file_main_proto_msgTypes[56] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AddGameReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddGameReq) ProtoMessage() {} + +func (x *AddGameReq) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[56] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddGameReq.ProtoReflect.Descriptor instead. +func (*AddGameReq) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{56} +} + +func (x *AddGameReq) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *AddGameReq) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *AddGameReq) GetStartAt() *timestamppb.Timestamp { + if x != nil { + return x.StartAt + } + return nil +} + +func (x *AddGameReq) GetScenarioId() int32 { + if x != nil { + return x.ScenarioId + } + return 0 +} + +type AddGameRsp struct { + state protoimpl.MessageState `protogen:"open.v1"` + Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` + Id int32 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AddGameRsp) Reset() { + *x = AddGameRsp{} + mi := &file_main_proto_msgTypes[57] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AddGameRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddGameRsp) ProtoMessage() {} + +func (x *AddGameRsp) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[57] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddGameRsp.ProtoReflect.Descriptor instead. +func (*AddGameRsp) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{57} +} + +func (x *AddGameRsp) GetError() string { + if x != nil { + return x.Error + } + return "" +} + +func (x *AddGameRsp) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +type GetGamesReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetGamesReq) Reset() { + *x = GetGamesReq{} + mi := &file_main_proto_msgTypes[58] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetGamesReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetGamesReq) ProtoMessage() {} + +func (x *GetGamesReq) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[58] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetGamesReq.ProtoReflect.Descriptor instead. +func (*GetGamesReq) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{58} +} + +type GetGamesRsp struct { + state protoimpl.MessageState `protogen:"open.v1"` + Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` + Games []*Game `protobuf:"bytes,2,rep,name=games,proto3" json:"games,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetGamesRsp) Reset() { + *x = GetGamesRsp{} + mi := &file_main_proto_msgTypes[59] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetGamesRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetGamesRsp) ProtoMessage() {} + +func (x *GetGamesRsp) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[59] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetGamesRsp.ProtoReflect.Descriptor instead. +func (*GetGamesRsp) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{59} +} + +func (x *GetGamesRsp) GetError() string { + if x != nil { + return x.Error + } + return "" +} + +func (x *GetGamesRsp) GetGames() []*Game { + if x != nil { + return x.Games + } + return nil +} + +type Game struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + StartAt *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=start_at,json=startAt,proto3" json:"start_at,omitempty"` + Status string `protobuf:"bytes,5,opt,name=status,proto3" json:"status,omitempty"` + Scenario *Scenario `protobuf:"bytes,6,opt,name=scenario,proto3" json:"scenario,omitempty"` + Teams []*Team `protobuf:"bytes,7,rep,name=teams,proto3" json:"teams,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Game) Reset() { + *x = Game{} + mi := &file_main_proto_msgTypes[60] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Game) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Game) ProtoMessage() {} + +func (x *Game) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[60] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Game.ProtoReflect.Descriptor instead. +func (*Game) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{60} +} + +func (x *Game) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Game) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Game) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Game) GetStartAt() *timestamppb.Timestamp { + if x != nil { + return x.StartAt + } + return nil +} + +func (x *Game) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +func (x *Game) GetScenario() *Scenario { + if x != nil { + return x.Scenario + } + return nil +} + +func (x *Game) GetTeams() []*Team { + if x != nil { + return x.Teams + } + return nil +} + +type Team struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Team) Reset() { + *x = Team{} + mi := &file_main_proto_msgTypes[61] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Team) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Team) ProtoMessage() {} + +func (x *Team) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[61] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Team.ProtoReflect.Descriptor instead. +func (*Team) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{61} +} + +func (x *Team) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Team) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type GetGameReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetGameReq) Reset() { + *x = GetGameReq{} + mi := &file_main_proto_msgTypes[62] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetGameReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetGameReq) ProtoMessage() {} + +func (x *GetGameReq) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[62] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetGameReq.ProtoReflect.Descriptor instead. +func (*GetGameReq) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{62} +} + +func (x *GetGameReq) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +type GetGameRsp struct { + state protoimpl.MessageState `protogen:"open.v1"` + Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` + Game *Game `protobuf:"bytes,2,opt,name=game,proto3" json:"game,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetGameRsp) Reset() { + *x = GetGameRsp{} + mi := &file_main_proto_msgTypes[63] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetGameRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetGameRsp) ProtoMessage() {} + +func (x *GetGameRsp) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[63] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetGameRsp.ProtoReflect.Descriptor instead. +func (*GetGameRsp) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{63} +} + +func (x *GetGameRsp) GetError() string { + if x != nil { + return x.Error + } + return "" +} + +func (x *GetGameRsp) GetGame() *Game { + if x != nil { + return x.Game + } + return nil +} + +type UpdateGameReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + StartAt *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=start_at,json=startAt,proto3" json:"start_at,omitempty"` + ScenarioId int32 `protobuf:"varint,5,opt,name=scenario_id,json=scenarioId,proto3" json:"scenario_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateGameReq) Reset() { + *x = UpdateGameReq{} + mi := &file_main_proto_msgTypes[64] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateGameReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateGameReq) ProtoMessage() {} + +func (x *UpdateGameReq) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[64] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateGameReq.ProtoReflect.Descriptor instead. +func (*UpdateGameReq) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{64} +} + +func (x *UpdateGameReq) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdateGameReq) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *UpdateGameReq) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *UpdateGameReq) GetStartAt() *timestamppb.Timestamp { + if x != nil { + return x.StartAt + } + return nil +} + +func (x *UpdateGameReq) GetScenarioId() int32 { + if x != nil { + return x.ScenarioId + } + return 0 +} + +type UpdateGameRsp struct { + state protoimpl.MessageState `protogen:"open.v1"` + Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateGameRsp) Reset() { + *x = UpdateGameRsp{} + mi := &file_main_proto_msgTypes[65] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateGameRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateGameRsp) ProtoMessage() {} + +func (x *UpdateGameRsp) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[65] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateGameRsp.ProtoReflect.Descriptor instead. +func (*UpdateGameRsp) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{65} +} + +func (x *UpdateGameRsp) GetError() string { + if x != nil { + return x.Error + } + return "" +} + +type DeleteGameReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteGameReq) Reset() { + *x = DeleteGameReq{} + mi := &file_main_proto_msgTypes[66] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteGameReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteGameReq) ProtoMessage() {} + +func (x *DeleteGameReq) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[66] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteGameReq.ProtoReflect.Descriptor instead. +func (*DeleteGameReq) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{66} +} + +func (x *DeleteGameReq) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +type DeleteGameRsp struct { + state protoimpl.MessageState `protogen:"open.v1"` + Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteGameRsp) Reset() { + *x = DeleteGameRsp{} + mi := &file_main_proto_msgTypes[67] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteGameRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteGameRsp) ProtoMessage() {} + +func (x *DeleteGameRsp) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[67] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteGameRsp.ProtoReflect.Descriptor instead. +func (*DeleteGameRsp) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{67} +} + +func (x *DeleteGameRsp) GetError() string { + if x != nil { + return x.Error + } + return "" +} + var File_main_proto protoreflect.FileDescriptor const file_main_proto_rawDesc = "" + @@ -2993,7 +3649,53 @@ const file_main_proto_rawDesc = "" + "\x02id\x18\x01 \x01(\x05R\x02id\x12\x12\n" + "\x04code\x18\x02 \x01(\tR\x04code\".\n" + "\x16DeleteScenarioPlaceRsp\x12\x14\n" + - "\x05error\x18\x01 \x01(\tR\x05error2\xc0,\n" + + "\x05error\x18\x01 \x01(\tR\x05error\"\x9a\x01\n" + + "\n" + + "AddGameReq\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12 \n" + + "\vdescription\x18\x02 \x01(\tR\vdescription\x125\n" + + "\bstart_at\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\astartAt\x12\x1f\n" + + "\vscenario_id\x18\x04 \x01(\x05R\n" + + "scenarioId\"2\n" + + "\n" + + "AddGameRsp\x12\x14\n" + + "\x05error\x18\x01 \x01(\tR\x05error\x12\x0e\n" + + "\x02id\x18\x02 \x01(\x05R\x02id\"\r\n" + + "\vGetGamesReq\"_\n" + + "\vGetGamesRsp\x12\x14\n" + + "\x05error\x18\x01 \x01(\tR\x05error\x12:\n" + + "\x05games\x18\x02 \x03(\v2$.crabs.evening_detective_server.GameR\x05games\"\x9d\x02\n" + + "\x04Game\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x05R\x02id\x12\x12\n" + + "\x04name\x18\x02 \x01(\tR\x04name\x12 \n" + + "\vdescription\x18\x03 \x01(\tR\vdescription\x125\n" + + "\bstart_at\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\astartAt\x12\x16\n" + + "\x06status\x18\x05 \x01(\tR\x06status\x12D\n" + + "\bscenario\x18\x06 \x01(\v2(.crabs.evening_detective_server.ScenarioR\bscenario\x12:\n" + + "\x05teams\x18\a \x03(\v2$.crabs.evening_detective_server.TeamR\x05teams\"*\n" + + "\x04Team\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x05R\x02id\x12\x12\n" + + "\x04name\x18\x02 \x01(\tR\x04name\"\x1c\n" + + "\n" + + "GetGameReq\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x05R\x02id\"\\\n" + + "\n" + + "GetGameRsp\x12\x14\n" + + "\x05error\x18\x01 \x01(\tR\x05error\x128\n" + + "\x04game\x18\x02 \x01(\v2$.crabs.evening_detective_server.GameR\x04game\"\xad\x01\n" + + "\rUpdateGameReq\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x05R\x02id\x12\x12\n" + + "\x04name\x18\x02 \x01(\tR\x04name\x12 \n" + + "\vdescription\x18\x03 \x01(\tR\vdescription\x125\n" + + "\bstart_at\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\astartAt\x12\x1f\n" + + "\vscenario_id\x18\x05 \x01(\x05R\n" + + "scenarioId\"%\n" + + "\rUpdateGameRsp\x12\x14\n" + + "\x05error\x18\x01 \x01(\tR\x05error\"\x1f\n" + + "\rDeleteGameReq\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x05R\x02id\"%\n" + + "\rDeleteGameRsp\x12\x14\n" + + "\x05error\x18\x01 \x01(\tR\x05error2\x863\n" + "\x16EveningDetectiveServer\x12\xa6\x01\n" + "\x04Ping\x12'.crabs.evening_detective_server.PingReq\x1a'.crabs.evening_detective_server.PingRsp\"L\x92A3\x12)Проверить доступностьb\x06\n" + "\x04\n" + @@ -3060,7 +3762,21 @@ const file_main_proto_rawDesc = "" + "\x13UpdateScenarioPlace\x126.crabs.evening_detective_server.UpdateScenarioPlaceReq\x1a6.crabs.evening_detective_server.UpdateScenarioPlaceRsp\"z\x92AK\n" + "\x1bТочки сценария\x12,Обновить точку сценария\x82\xd3\xe4\x93\x02&:\x01*\x1a!/api/scenarios/{id}/places/{code}\x12\xfc\x01\n" + "\x13DeleteScenarioPlace\x126.crabs.evening_detective_server.DeleteScenarioPlaceReq\x1a6.crabs.evening_detective_server.DeleteScenarioPlaceRsp\"u\x92AI\n" + - "\x1bТочки сценария\x12*Удалить точку сценария\x82\xd3\xe4\x93\x02#*!/api/scenarios/{id}/places/{code}B\xd7\x01\x92A\xc8\x01\x12U\n" + + "\x1bТочки сценария\x12*Удалить точку сценария\x82\xd3\xe4\x93\x02#*!/api/scenarios/{id}/places/{code}\x12\x9e\x01\n" + + "\aAddGame\x12*.crabs.evening_detective_server.AddGameReq\x1a*.crabs.evening_detective_server.AddGameRsp\";\x92A#\n" + + "\bИгры\x12\x17Создать игру\x82\xd3\xe4\x93\x02\x0f:\x01*\"\n" + + "/api/games\x12\xa0\x01\n" + + "\bGetGames\x12+.crabs.evening_detective_server.GetGamesReq\x1a+.crabs.evening_detective_server.GetGamesRsp\":\x92A%\n" + + "\bИгры\x12\x19Получить игры\x82\xd3\xe4\x93\x02\f\x12\n" + + "/api/games\x12\xa2\x01\n" + + "\aGetGame\x12*.crabs.evening_detective_server.GetGameReq\x1a*.crabs.evening_detective_server.GetGameRsp\"?\x92A%\n" + + "\bИгры\x12\x19Получить игру\x82\xd3\xe4\x93\x02\x11\x12\x0f/api/games/{id}\x12\xae\x01\n" + + "\n" + + "UpdateGame\x12-.crabs.evening_detective_server.UpdateGameReq\x1a-.crabs.evening_detective_server.UpdateGameRsp\"B\x92A%\n" + + "\bИгры\x12\x19Обновить игру\x82\xd3\xe4\x93\x02\x14:\x01*\x1a\x0f/api/games/{id}\x12\xa9\x01\n" + + "\n" + + "DeleteGame\x12-.crabs.evening_detective_server.DeleteGameReq\x1a-.crabs.evening_detective_server.DeleteGameRsp\"=\x92A#\n" + + "\bИгры\x12\x17Удалить игру\x82\xd3\xe4\x93\x02\x11*\x0f/api/games/{id}B\xd7\x01\x92A\xc8\x01\x12U\n" + "KДокументация сервиса \"Вечерний детектив\"2\x06v0.1.0Z]\n" + "[\n" + "\n" + @@ -3081,7 +3797,7 @@ func file_main_proto_rawDescGZIP() []byte { return file_main_proto_rawDescData } -var file_main_proto_msgTypes = make([]protoimpl.MessageInfo, 56) +var file_main_proto_msgTypes = make([]protoimpl.MessageInfo, 68) var file_main_proto_goTypes = []any{ (*PingReq)(nil), // 0: crabs.evening_detective_server.PingReq (*PingRsp)(nil), // 1: crabs.evening_detective_server.PingRsp @@ -3139,12 +3855,24 @@ var file_main_proto_goTypes = []any{ (*UpdateScenarioPlaceRsp)(nil), // 53: crabs.evening_detective_server.UpdateScenarioPlaceRsp (*DeleteScenarioPlaceReq)(nil), // 54: crabs.evening_detective_server.DeleteScenarioPlaceReq (*DeleteScenarioPlaceRsp)(nil), // 55: crabs.evening_detective_server.DeleteScenarioPlaceRsp - (*timestamppb.Timestamp)(nil), // 56: google.protobuf.Timestamp - (*httpbody.HttpBody)(nil), // 57: google.api.HttpBody + (*AddGameReq)(nil), // 56: crabs.evening_detective_server.AddGameReq + (*AddGameRsp)(nil), // 57: crabs.evening_detective_server.AddGameRsp + (*GetGamesReq)(nil), // 58: crabs.evening_detective_server.GetGamesReq + (*GetGamesRsp)(nil), // 59: crabs.evening_detective_server.GetGamesRsp + (*Game)(nil), // 60: crabs.evening_detective_server.Game + (*Team)(nil), // 61: crabs.evening_detective_server.Team + (*GetGameReq)(nil), // 62: crabs.evening_detective_server.GetGameReq + (*GetGameRsp)(nil), // 63: crabs.evening_detective_server.GetGameRsp + (*UpdateGameReq)(nil), // 64: crabs.evening_detective_server.UpdateGameReq + (*UpdateGameRsp)(nil), // 65: crabs.evening_detective_server.UpdateGameRsp + (*DeleteGameReq)(nil), // 66: crabs.evening_detective_server.DeleteGameReq + (*DeleteGameRsp)(nil), // 67: crabs.evening_detective_server.DeleteGameRsp + (*timestamppb.Timestamp)(nil), // 68: google.protobuf.Timestamp + (*httpbody.HttpBody)(nil), // 69: google.api.HttpBody } var file_main_proto_depIdxs = []int32{ 14, // 0: crabs.evening_detective_server.GetUsersRsp.users:type_name -> crabs.evening_detective_server.User - 56, // 1: crabs.evening_detective_server.User.created_at:type_name -> google.protobuf.Timestamp + 68, // 1: crabs.evening_detective_server.User.created_at:type_name -> google.protobuf.Timestamp 14, // 2: crabs.evening_detective_server.GetUserByIdRsp.user:type_name -> crabs.evening_detective_server.User 14, // 3: crabs.evening_detective_server.GetMeRsp.user:type_name -> crabs.evening_detective_server.User 36, // 4: crabs.evening_detective_server.GetMyScenariosRsp.scenarios:type_name -> crabs.evening_detective_server.Scenario @@ -3152,9 +3880,9 @@ var file_main_proto_depIdxs = []int32{ 36, // 6: crabs.evening_detective_server.GetScenarioRsp.scenario:type_name -> crabs.evening_detective_server.Scenario 37, // 7: crabs.evening_detective_server.Scenario.story:type_name -> crabs.evening_detective_server.Story 14, // 8: crabs.evening_detective_server.Scenario.author:type_name -> crabs.evening_detective_server.User - 56, // 9: crabs.evening_detective_server.Scenario.updated_at:type_name -> google.protobuf.Timestamp - 56, // 10: crabs.evening_detective_server.Scenario.created_at:type_name -> google.protobuf.Timestamp - 56, // 11: crabs.evening_detective_server.Scenario.published_at:type_name -> google.protobuf.Timestamp + 68, // 9: crabs.evening_detective_server.Scenario.updated_at:type_name -> google.protobuf.Timestamp + 68, // 10: crabs.evening_detective_server.Scenario.created_at:type_name -> google.protobuf.Timestamp + 68, // 11: crabs.evening_detective_server.Scenario.published_at:type_name -> google.protobuf.Timestamp 38, // 12: crabs.evening_detective_server.Story.places:type_name -> crabs.evening_detective_server.Place 39, // 13: crabs.evening_detective_server.Place.applications:type_name -> crabs.evening_detective_server.Application 40, // 14: crabs.evening_detective_server.Place.doors:type_name -> crabs.evening_detective_server.Door @@ -3162,63 +3890,80 @@ var file_main_proto_depIdxs = []int32{ 41, // 16: crabs.evening_detective_server.Door.keys:type_name -> crabs.evening_detective_server.Key 38, // 17: crabs.evening_detective_server.AddScenarioPlaceReq.place:type_name -> crabs.evening_detective_server.Place 38, // 18: crabs.evening_detective_server.UpdateScenarioPlaceReq.place:type_name -> crabs.evening_detective_server.Place - 0, // 19: crabs.evening_detective_server.EveningDetectiveServer.Ping:input_type -> crabs.evening_detective_server.PingReq - 2, // 20: crabs.evening_detective_server.EveningDetectiveServer.Echo:input_type -> crabs.evening_detective_server.EchoReq - 4, // 21: crabs.evening_detective_server.EveningDetectiveServer.Signup:input_type -> crabs.evening_detective_server.SignupReq - 6, // 22: crabs.evening_detective_server.EveningDetectiveServer.RefreshPassword:input_type -> crabs.evening_detective_server.RefreshPasswordReq - 8, // 23: crabs.evening_detective_server.EveningDetectiveServer.Login:input_type -> crabs.evening_detective_server.LoginReq - 10, // 24: crabs.evening_detective_server.EveningDetectiveServer.Refresh:input_type -> crabs.evening_detective_server.RefreshReq - 12, // 25: crabs.evening_detective_server.EveningDetectiveServer.GetUsers:input_type -> crabs.evening_detective_server.GetUsersReq - 15, // 26: crabs.evening_detective_server.EveningDetectiveServer.GetUserById:input_type -> crabs.evening_detective_server.GetUserByIdReq - 17, // 27: crabs.evening_detective_server.EveningDetectiveServer.GetMe:input_type -> crabs.evening_detective_server.GetMeReq - 19, // 28: crabs.evening_detective_server.EveningDetectiveServer.AddUserRole:input_type -> crabs.evening_detective_server.AddUserRoleReq - 21, // 29: crabs.evening_detective_server.EveningDetectiveServer.DeleteUserRole:input_type -> crabs.evening_detective_server.DeleteUserRoleReq - 23, // 30: crabs.evening_detective_server.EveningDetectiveServer.GetPermissions:input_type -> crabs.evening_detective_server.GetPermissionsReq - 25, // 31: crabs.evening_detective_server.EveningDetectiveServer.UploadFile:input_type -> crabs.evening_detective_server.UploadFileReq - 27, // 32: crabs.evening_detective_server.EveningDetectiveServer.DownloadFile:input_type -> crabs.evening_detective_server.DownloadFileReq - 28, // 33: crabs.evening_detective_server.EveningDetectiveServer.AddScenario:input_type -> crabs.evening_detective_server.AddScenarioReq - 30, // 34: crabs.evening_detective_server.EveningDetectiveServer.GetMyScenarios:input_type -> crabs.evening_detective_server.GetMyScenariosReq - 32, // 35: crabs.evening_detective_server.EveningDetectiveServer.GetScenariosCatalog:input_type -> crabs.evening_detective_server.GetScenariosCatalogReq - 34, // 36: crabs.evening_detective_server.EveningDetectiveServer.GetFullScenario:input_type -> crabs.evening_detective_server.GetScenarioReq - 34, // 37: crabs.evening_detective_server.EveningDetectiveServer.GetScenario:input_type -> crabs.evening_detective_server.GetScenarioReq - 42, // 38: crabs.evening_detective_server.EveningDetectiveServer.UpdateScenario:input_type -> crabs.evening_detective_server.UpdateScenarioReq - 44, // 39: crabs.evening_detective_server.EveningDetectiveServer.PublicScenario:input_type -> crabs.evening_detective_server.PublicScenarioReq - 46, // 40: crabs.evening_detective_server.EveningDetectiveServer.DraftScenario:input_type -> crabs.evening_detective_server.DraftScenarioReq - 48, // 41: crabs.evening_detective_server.EveningDetectiveServer.DeleteScenario:input_type -> crabs.evening_detective_server.DeleteScenarioReq - 50, // 42: crabs.evening_detective_server.EveningDetectiveServer.AddScenarioPlace:input_type -> crabs.evening_detective_server.AddScenarioPlaceReq - 52, // 43: crabs.evening_detective_server.EveningDetectiveServer.UpdateScenarioPlace:input_type -> crabs.evening_detective_server.UpdateScenarioPlaceReq - 54, // 44: crabs.evening_detective_server.EveningDetectiveServer.DeleteScenarioPlace:input_type -> crabs.evening_detective_server.DeleteScenarioPlaceReq - 1, // 45: crabs.evening_detective_server.EveningDetectiveServer.Ping:output_type -> crabs.evening_detective_server.PingRsp - 3, // 46: crabs.evening_detective_server.EveningDetectiveServer.Echo:output_type -> crabs.evening_detective_server.EchoRsp - 5, // 47: crabs.evening_detective_server.EveningDetectiveServer.Signup:output_type -> crabs.evening_detective_server.SignupRsp - 7, // 48: crabs.evening_detective_server.EveningDetectiveServer.RefreshPassword:output_type -> crabs.evening_detective_server.RefreshPasswordRsp - 9, // 49: crabs.evening_detective_server.EveningDetectiveServer.Login:output_type -> crabs.evening_detective_server.LoginRsp - 11, // 50: crabs.evening_detective_server.EveningDetectiveServer.Refresh:output_type -> crabs.evening_detective_server.RefreshRsp - 13, // 51: crabs.evening_detective_server.EveningDetectiveServer.GetUsers:output_type -> crabs.evening_detective_server.GetUsersRsp - 16, // 52: crabs.evening_detective_server.EveningDetectiveServer.GetUserById:output_type -> crabs.evening_detective_server.GetUserByIdRsp - 18, // 53: crabs.evening_detective_server.EveningDetectiveServer.GetMe:output_type -> crabs.evening_detective_server.GetMeRsp - 20, // 54: crabs.evening_detective_server.EveningDetectiveServer.AddUserRole:output_type -> crabs.evening_detective_server.AddUserRoleRsp - 22, // 55: crabs.evening_detective_server.EveningDetectiveServer.DeleteUserRole:output_type -> crabs.evening_detective_server.DeleteUserRoleRsp - 24, // 56: crabs.evening_detective_server.EveningDetectiveServer.GetPermissions:output_type -> crabs.evening_detective_server.GetPermissionsRsp - 26, // 57: crabs.evening_detective_server.EveningDetectiveServer.UploadFile:output_type -> crabs.evening_detective_server.UploadFileRsp - 57, // 58: crabs.evening_detective_server.EveningDetectiveServer.DownloadFile:output_type -> google.api.HttpBody - 29, // 59: crabs.evening_detective_server.EveningDetectiveServer.AddScenario:output_type -> crabs.evening_detective_server.AddScenarioRsp - 31, // 60: crabs.evening_detective_server.EveningDetectiveServer.GetMyScenarios:output_type -> crabs.evening_detective_server.GetMyScenariosRsp - 33, // 61: crabs.evening_detective_server.EveningDetectiveServer.GetScenariosCatalog:output_type -> crabs.evening_detective_server.GetScenariosCatalogRsp - 35, // 62: crabs.evening_detective_server.EveningDetectiveServer.GetFullScenario:output_type -> crabs.evening_detective_server.GetScenarioRsp - 35, // 63: crabs.evening_detective_server.EveningDetectiveServer.GetScenario:output_type -> crabs.evening_detective_server.GetScenarioRsp - 43, // 64: crabs.evening_detective_server.EveningDetectiveServer.UpdateScenario:output_type -> crabs.evening_detective_server.UpdateScenarioRsp - 45, // 65: crabs.evening_detective_server.EveningDetectiveServer.PublicScenario:output_type -> crabs.evening_detective_server.PublicScenarioRsp - 47, // 66: crabs.evening_detective_server.EveningDetectiveServer.DraftScenario:output_type -> crabs.evening_detective_server.DraftScenarioRsp - 49, // 67: crabs.evening_detective_server.EveningDetectiveServer.DeleteScenario:output_type -> crabs.evening_detective_server.DeleteScenarioRsp - 51, // 68: crabs.evening_detective_server.EveningDetectiveServer.AddScenarioPlace:output_type -> crabs.evening_detective_server.AddScenarioPlaceRsp - 53, // 69: crabs.evening_detective_server.EveningDetectiveServer.UpdateScenarioPlace:output_type -> crabs.evening_detective_server.UpdateScenarioPlaceRsp - 55, // 70: crabs.evening_detective_server.EveningDetectiveServer.DeleteScenarioPlace:output_type -> crabs.evening_detective_server.DeleteScenarioPlaceRsp - 45, // [45:71] is the sub-list for method output_type - 19, // [19:45] is the sub-list for method input_type - 19, // [19:19] is the sub-list for extension type_name - 19, // [19:19] is the sub-list for extension extendee - 0, // [0:19] is the sub-list for field type_name + 68, // 19: crabs.evening_detective_server.AddGameReq.start_at:type_name -> google.protobuf.Timestamp + 60, // 20: crabs.evening_detective_server.GetGamesRsp.games:type_name -> crabs.evening_detective_server.Game + 68, // 21: crabs.evening_detective_server.Game.start_at:type_name -> google.protobuf.Timestamp + 36, // 22: crabs.evening_detective_server.Game.scenario:type_name -> crabs.evening_detective_server.Scenario + 61, // 23: crabs.evening_detective_server.Game.teams:type_name -> crabs.evening_detective_server.Team + 60, // 24: crabs.evening_detective_server.GetGameRsp.game:type_name -> crabs.evening_detective_server.Game + 68, // 25: crabs.evening_detective_server.UpdateGameReq.start_at:type_name -> google.protobuf.Timestamp + 0, // 26: crabs.evening_detective_server.EveningDetectiveServer.Ping:input_type -> crabs.evening_detective_server.PingReq + 2, // 27: crabs.evening_detective_server.EveningDetectiveServer.Echo:input_type -> crabs.evening_detective_server.EchoReq + 4, // 28: crabs.evening_detective_server.EveningDetectiveServer.Signup:input_type -> crabs.evening_detective_server.SignupReq + 6, // 29: crabs.evening_detective_server.EveningDetectiveServer.RefreshPassword:input_type -> crabs.evening_detective_server.RefreshPasswordReq + 8, // 30: crabs.evening_detective_server.EveningDetectiveServer.Login:input_type -> crabs.evening_detective_server.LoginReq + 10, // 31: crabs.evening_detective_server.EveningDetectiveServer.Refresh:input_type -> crabs.evening_detective_server.RefreshReq + 12, // 32: crabs.evening_detective_server.EveningDetectiveServer.GetUsers:input_type -> crabs.evening_detective_server.GetUsersReq + 15, // 33: crabs.evening_detective_server.EveningDetectiveServer.GetUserById:input_type -> crabs.evening_detective_server.GetUserByIdReq + 17, // 34: crabs.evening_detective_server.EveningDetectiveServer.GetMe:input_type -> crabs.evening_detective_server.GetMeReq + 19, // 35: crabs.evening_detective_server.EveningDetectiveServer.AddUserRole:input_type -> crabs.evening_detective_server.AddUserRoleReq + 21, // 36: crabs.evening_detective_server.EveningDetectiveServer.DeleteUserRole:input_type -> crabs.evening_detective_server.DeleteUserRoleReq + 23, // 37: crabs.evening_detective_server.EveningDetectiveServer.GetPermissions:input_type -> crabs.evening_detective_server.GetPermissionsReq + 25, // 38: crabs.evening_detective_server.EveningDetectiveServer.UploadFile:input_type -> crabs.evening_detective_server.UploadFileReq + 27, // 39: crabs.evening_detective_server.EveningDetectiveServer.DownloadFile:input_type -> crabs.evening_detective_server.DownloadFileReq + 28, // 40: crabs.evening_detective_server.EveningDetectiveServer.AddScenario:input_type -> crabs.evening_detective_server.AddScenarioReq + 30, // 41: crabs.evening_detective_server.EveningDetectiveServer.GetMyScenarios:input_type -> crabs.evening_detective_server.GetMyScenariosReq + 32, // 42: crabs.evening_detective_server.EveningDetectiveServer.GetScenariosCatalog:input_type -> crabs.evening_detective_server.GetScenariosCatalogReq + 34, // 43: crabs.evening_detective_server.EveningDetectiveServer.GetFullScenario:input_type -> crabs.evening_detective_server.GetScenarioReq + 34, // 44: crabs.evening_detective_server.EveningDetectiveServer.GetScenario:input_type -> crabs.evening_detective_server.GetScenarioReq + 42, // 45: crabs.evening_detective_server.EveningDetectiveServer.UpdateScenario:input_type -> crabs.evening_detective_server.UpdateScenarioReq + 44, // 46: crabs.evening_detective_server.EveningDetectiveServer.PublicScenario:input_type -> crabs.evening_detective_server.PublicScenarioReq + 46, // 47: crabs.evening_detective_server.EveningDetectiveServer.DraftScenario:input_type -> crabs.evening_detective_server.DraftScenarioReq + 48, // 48: crabs.evening_detective_server.EveningDetectiveServer.DeleteScenario:input_type -> crabs.evening_detective_server.DeleteScenarioReq + 50, // 49: crabs.evening_detective_server.EveningDetectiveServer.AddScenarioPlace:input_type -> crabs.evening_detective_server.AddScenarioPlaceReq + 52, // 50: crabs.evening_detective_server.EveningDetectiveServer.UpdateScenarioPlace:input_type -> crabs.evening_detective_server.UpdateScenarioPlaceReq + 54, // 51: crabs.evening_detective_server.EveningDetectiveServer.DeleteScenarioPlace:input_type -> crabs.evening_detective_server.DeleteScenarioPlaceReq + 56, // 52: crabs.evening_detective_server.EveningDetectiveServer.AddGame:input_type -> crabs.evening_detective_server.AddGameReq + 58, // 53: crabs.evening_detective_server.EveningDetectiveServer.GetGames:input_type -> crabs.evening_detective_server.GetGamesReq + 62, // 54: crabs.evening_detective_server.EveningDetectiveServer.GetGame:input_type -> crabs.evening_detective_server.GetGameReq + 64, // 55: crabs.evening_detective_server.EveningDetectiveServer.UpdateGame:input_type -> crabs.evening_detective_server.UpdateGameReq + 66, // 56: crabs.evening_detective_server.EveningDetectiveServer.DeleteGame:input_type -> crabs.evening_detective_server.DeleteGameReq + 1, // 57: crabs.evening_detective_server.EveningDetectiveServer.Ping:output_type -> crabs.evening_detective_server.PingRsp + 3, // 58: crabs.evening_detective_server.EveningDetectiveServer.Echo:output_type -> crabs.evening_detective_server.EchoRsp + 5, // 59: crabs.evening_detective_server.EveningDetectiveServer.Signup:output_type -> crabs.evening_detective_server.SignupRsp + 7, // 60: crabs.evening_detective_server.EveningDetectiveServer.RefreshPassword:output_type -> crabs.evening_detective_server.RefreshPasswordRsp + 9, // 61: crabs.evening_detective_server.EveningDetectiveServer.Login:output_type -> crabs.evening_detective_server.LoginRsp + 11, // 62: crabs.evening_detective_server.EveningDetectiveServer.Refresh:output_type -> crabs.evening_detective_server.RefreshRsp + 13, // 63: crabs.evening_detective_server.EveningDetectiveServer.GetUsers:output_type -> crabs.evening_detective_server.GetUsersRsp + 16, // 64: crabs.evening_detective_server.EveningDetectiveServer.GetUserById:output_type -> crabs.evening_detective_server.GetUserByIdRsp + 18, // 65: crabs.evening_detective_server.EveningDetectiveServer.GetMe:output_type -> crabs.evening_detective_server.GetMeRsp + 20, // 66: crabs.evening_detective_server.EveningDetectiveServer.AddUserRole:output_type -> crabs.evening_detective_server.AddUserRoleRsp + 22, // 67: crabs.evening_detective_server.EveningDetectiveServer.DeleteUserRole:output_type -> crabs.evening_detective_server.DeleteUserRoleRsp + 24, // 68: crabs.evening_detective_server.EveningDetectiveServer.GetPermissions:output_type -> crabs.evening_detective_server.GetPermissionsRsp + 26, // 69: crabs.evening_detective_server.EveningDetectiveServer.UploadFile:output_type -> crabs.evening_detective_server.UploadFileRsp + 69, // 70: crabs.evening_detective_server.EveningDetectiveServer.DownloadFile:output_type -> google.api.HttpBody + 29, // 71: crabs.evening_detective_server.EveningDetectiveServer.AddScenario:output_type -> crabs.evening_detective_server.AddScenarioRsp + 31, // 72: crabs.evening_detective_server.EveningDetectiveServer.GetMyScenarios:output_type -> crabs.evening_detective_server.GetMyScenariosRsp + 33, // 73: crabs.evening_detective_server.EveningDetectiveServer.GetScenariosCatalog:output_type -> crabs.evening_detective_server.GetScenariosCatalogRsp + 35, // 74: crabs.evening_detective_server.EveningDetectiveServer.GetFullScenario:output_type -> crabs.evening_detective_server.GetScenarioRsp + 35, // 75: crabs.evening_detective_server.EveningDetectiveServer.GetScenario:output_type -> crabs.evening_detective_server.GetScenarioRsp + 43, // 76: crabs.evening_detective_server.EveningDetectiveServer.UpdateScenario:output_type -> crabs.evening_detective_server.UpdateScenarioRsp + 45, // 77: crabs.evening_detective_server.EveningDetectiveServer.PublicScenario:output_type -> crabs.evening_detective_server.PublicScenarioRsp + 47, // 78: crabs.evening_detective_server.EveningDetectiveServer.DraftScenario:output_type -> crabs.evening_detective_server.DraftScenarioRsp + 49, // 79: crabs.evening_detective_server.EveningDetectiveServer.DeleteScenario:output_type -> crabs.evening_detective_server.DeleteScenarioRsp + 51, // 80: crabs.evening_detective_server.EveningDetectiveServer.AddScenarioPlace:output_type -> crabs.evening_detective_server.AddScenarioPlaceRsp + 53, // 81: crabs.evening_detective_server.EveningDetectiveServer.UpdateScenarioPlace:output_type -> crabs.evening_detective_server.UpdateScenarioPlaceRsp + 55, // 82: crabs.evening_detective_server.EveningDetectiveServer.DeleteScenarioPlace:output_type -> crabs.evening_detective_server.DeleteScenarioPlaceRsp + 57, // 83: crabs.evening_detective_server.EveningDetectiveServer.AddGame:output_type -> crabs.evening_detective_server.AddGameRsp + 59, // 84: crabs.evening_detective_server.EveningDetectiveServer.GetGames:output_type -> crabs.evening_detective_server.GetGamesRsp + 63, // 85: crabs.evening_detective_server.EveningDetectiveServer.GetGame:output_type -> crabs.evening_detective_server.GetGameRsp + 65, // 86: crabs.evening_detective_server.EveningDetectiveServer.UpdateGame:output_type -> crabs.evening_detective_server.UpdateGameRsp + 67, // 87: crabs.evening_detective_server.EveningDetectiveServer.DeleteGame:output_type -> crabs.evening_detective_server.DeleteGameRsp + 57, // [57:88] is the sub-list for method output_type + 26, // [26:57] is the sub-list for method input_type + 26, // [26:26] is the sub-list for extension type_name + 26, // [26:26] is the sub-list for extension extendee + 0, // [0:26] is the sub-list for field type_name } func init() { file_main_proto_init() } @@ -3233,7 +3978,7 @@ func file_main_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_main_proto_rawDesc), len(file_main_proto_rawDesc)), NumEnums: 0, - NumMessages: 56, + NumMessages: 68, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/main.pb.gw.go b/proto/main.pb.gw.go index af350cc..aadd90d 100644 --- a/proto/main.pb.gw.go +++ b/proto/main.pb.gw.go @@ -939,6 +939,177 @@ func local_request_EveningDetectiveServer_DeleteScenarioPlace_0(ctx context.Cont return msg, metadata, err } +func request_EveningDetectiveServer_AddGame_0(ctx context.Context, marshaler runtime.Marshaler, client EveningDetectiveServerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq AddGameReq + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } + msg, err := client.AddGame(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_EveningDetectiveServer_AddGame_0(ctx context.Context, marshaler runtime.Marshaler, server EveningDetectiveServerServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq AddGameReq + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.AddGame(ctx, &protoReq) + return msg, metadata, err +} + +func request_EveningDetectiveServer_GetGames_0(ctx context.Context, marshaler runtime.Marshaler, client EveningDetectiveServerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetGamesReq + metadata runtime.ServerMetadata + ) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } + msg, err := client.GetGames(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_EveningDetectiveServer_GetGames_0(ctx context.Context, marshaler runtime.Marshaler, server EveningDetectiveServerServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetGamesReq + metadata runtime.ServerMetadata + ) + msg, err := server.GetGames(ctx, &protoReq) + return msg, metadata, err +} + +func request_EveningDetectiveServer_GetGame_0(ctx context.Context, marshaler runtime.Marshaler, client EveningDetectiveServerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetGameReq + metadata runtime.ServerMetadata + err error + ) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int32(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.GetGame(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_EveningDetectiveServer_GetGame_0(ctx context.Context, marshaler runtime.Marshaler, server EveningDetectiveServerServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetGameReq + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int32(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.GetGame(ctx, &protoReq) + return msg, metadata, err +} + +func request_EveningDetectiveServer_UpdateGame_0(ctx context.Context, marshaler runtime.Marshaler, client EveningDetectiveServerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateGameReq + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int32(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.UpdateGame(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_EveningDetectiveServer_UpdateGame_0(ctx context.Context, marshaler runtime.Marshaler, server EveningDetectiveServerServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateGameReq + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int32(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.UpdateGame(ctx, &protoReq) + return msg, metadata, err +} + +func request_EveningDetectiveServer_DeleteGame_0(ctx context.Context, marshaler runtime.Marshaler, client EveningDetectiveServerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteGameReq + metadata runtime.ServerMetadata + err error + ) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int32(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.DeleteGame(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_EveningDetectiveServer_DeleteGame_0(ctx context.Context, marshaler runtime.Marshaler, server EveningDetectiveServerServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteGameReq + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int32(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.DeleteGame(ctx, &protoReq) + return msg, metadata, err +} + // RegisterEveningDetectiveServerHandlerServer registers the http handlers for service EveningDetectiveServer to "mux". // UnaryRPC :call EveningDetectiveServerServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -1465,6 +1636,106 @@ func RegisterEveningDetectiveServerHandlerServer(ctx context.Context, mux *runti } forward_EveningDetectiveServer_DeleteScenarioPlace_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) + mux.Handle(http.MethodPost, pattern_EveningDetectiveServer_AddGame_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/crabs.evening_detective_server.EveningDetectiveServer/AddGame", runtime.WithHTTPPathPattern("/api/games")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_EveningDetectiveServer_AddGame_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_EveningDetectiveServer_AddGame_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_EveningDetectiveServer_GetGames_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/crabs.evening_detective_server.EveningDetectiveServer/GetGames", runtime.WithHTTPPathPattern("/api/games")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_EveningDetectiveServer_GetGames_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_EveningDetectiveServer_GetGames_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_EveningDetectiveServer_GetGame_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/crabs.evening_detective_server.EveningDetectiveServer/GetGame", runtime.WithHTTPPathPattern("/api/games/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_EveningDetectiveServer_GetGame_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_EveningDetectiveServer_GetGame_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_EveningDetectiveServer_UpdateGame_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/crabs.evening_detective_server.EveningDetectiveServer/UpdateGame", runtime.WithHTTPPathPattern("/api/games/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_EveningDetectiveServer_UpdateGame_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_EveningDetectiveServer_UpdateGame_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_EveningDetectiveServer_DeleteGame_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/crabs.evening_detective_server.EveningDetectiveServer/DeleteGame", runtime.WithHTTPPathPattern("/api/games/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_EveningDetectiveServer_DeleteGame_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_EveningDetectiveServer_DeleteGame_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) return nil } @@ -1947,6 +2218,91 @@ func RegisterEveningDetectiveServerHandlerClient(ctx context.Context, mux *runti } forward_EveningDetectiveServer_DeleteScenarioPlace_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) + mux.Handle(http.MethodPost, pattern_EveningDetectiveServer_AddGame_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/crabs.evening_detective_server.EveningDetectiveServer/AddGame", runtime.WithHTTPPathPattern("/api/games")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_EveningDetectiveServer_AddGame_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_EveningDetectiveServer_AddGame_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_EveningDetectiveServer_GetGames_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/crabs.evening_detective_server.EveningDetectiveServer/GetGames", runtime.WithHTTPPathPattern("/api/games")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_EveningDetectiveServer_GetGames_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_EveningDetectiveServer_GetGames_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_EveningDetectiveServer_GetGame_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/crabs.evening_detective_server.EveningDetectiveServer/GetGame", runtime.WithHTTPPathPattern("/api/games/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_EveningDetectiveServer_GetGame_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_EveningDetectiveServer_GetGame_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_EveningDetectiveServer_UpdateGame_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/crabs.evening_detective_server.EveningDetectiveServer/UpdateGame", runtime.WithHTTPPathPattern("/api/games/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_EveningDetectiveServer_UpdateGame_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_EveningDetectiveServer_UpdateGame_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_EveningDetectiveServer_DeleteGame_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/crabs.evening_detective_server.EveningDetectiveServer/DeleteGame", runtime.WithHTTPPathPattern("/api/games/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_EveningDetectiveServer_DeleteGame_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_EveningDetectiveServer_DeleteGame_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) return nil } @@ -1977,6 +2333,11 @@ var ( pattern_EveningDetectiveServer_AddScenarioPlace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"api", "scenarios", "id", "places"}, "")) pattern_EveningDetectiveServer_UpdateScenarioPlace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"api", "scenarios", "id", "places", "code"}, "")) pattern_EveningDetectiveServer_DeleteScenarioPlace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"api", "scenarios", "id", "places", "code"}, "")) + pattern_EveningDetectiveServer_AddGame_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"api", "games"}, "")) + pattern_EveningDetectiveServer_GetGames_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"api", "games"}, "")) + pattern_EveningDetectiveServer_GetGame_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"api", "games", "id"}, "")) + pattern_EveningDetectiveServer_UpdateGame_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"api", "games", "id"}, "")) + pattern_EveningDetectiveServer_DeleteGame_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"api", "games", "id"}, "")) ) var ( @@ -2006,4 +2367,9 @@ var ( forward_EveningDetectiveServer_AddScenarioPlace_0 = runtime.ForwardResponseMessage forward_EveningDetectiveServer_UpdateScenarioPlace_0 = runtime.ForwardResponseMessage forward_EveningDetectiveServer_DeleteScenarioPlace_0 = runtime.ForwardResponseMessage + forward_EveningDetectiveServer_AddGame_0 = runtime.ForwardResponseMessage + forward_EveningDetectiveServer_GetGames_0 = runtime.ForwardResponseMessage + forward_EveningDetectiveServer_GetGame_0 = runtime.ForwardResponseMessage + forward_EveningDetectiveServer_UpdateGame_0 = runtime.ForwardResponseMessage + forward_EveningDetectiveServer_DeleteGame_0 = runtime.ForwardResponseMessage ) diff --git a/proto/main_grpc.pb.go b/proto/main_grpc.pb.go index 5d68238..d68e00c 100644 --- a/proto/main_grpc.pb.go +++ b/proto/main_grpc.pb.go @@ -46,6 +46,11 @@ const ( EveningDetectiveServer_AddScenarioPlace_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/AddScenarioPlace" EveningDetectiveServer_UpdateScenarioPlace_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/UpdateScenarioPlace" EveningDetectiveServer_DeleteScenarioPlace_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/DeleteScenarioPlace" + EveningDetectiveServer_AddGame_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/AddGame" + EveningDetectiveServer_GetGames_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/GetGames" + EveningDetectiveServer_GetGame_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/GetGame" + EveningDetectiveServer_UpdateGame_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/UpdateGame" + EveningDetectiveServer_DeleteGame_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/DeleteGame" ) // EveningDetectiveServerClient is the client API for EveningDetectiveServer service. @@ -78,6 +83,11 @@ type EveningDetectiveServerClient interface { AddScenarioPlace(ctx context.Context, in *AddScenarioPlaceReq, opts ...grpc.CallOption) (*AddScenarioPlaceRsp, error) UpdateScenarioPlace(ctx context.Context, in *UpdateScenarioPlaceReq, opts ...grpc.CallOption) (*UpdateScenarioPlaceRsp, error) DeleteScenarioPlace(ctx context.Context, in *DeleteScenarioPlaceReq, opts ...grpc.CallOption) (*DeleteScenarioPlaceRsp, error) + AddGame(ctx context.Context, in *AddGameReq, opts ...grpc.CallOption) (*AddGameRsp, error) + GetGames(ctx context.Context, in *GetGamesReq, opts ...grpc.CallOption) (*GetGamesRsp, error) + GetGame(ctx context.Context, in *GetGameReq, opts ...grpc.CallOption) (*GetGameRsp, error) + UpdateGame(ctx context.Context, in *UpdateGameReq, opts ...grpc.CallOption) (*UpdateGameRsp, error) + DeleteGame(ctx context.Context, in *DeleteGameReq, opts ...grpc.CallOption) (*DeleteGameRsp, error) } type eveningDetectiveServerClient struct { @@ -348,6 +358,56 @@ func (c *eveningDetectiveServerClient) DeleteScenarioPlace(ctx context.Context, return out, nil } +func (c *eveningDetectiveServerClient) AddGame(ctx context.Context, in *AddGameReq, opts ...grpc.CallOption) (*AddGameRsp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(AddGameRsp) + err := c.cc.Invoke(ctx, EveningDetectiveServer_AddGame_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *eveningDetectiveServerClient) GetGames(ctx context.Context, in *GetGamesReq, opts ...grpc.CallOption) (*GetGamesRsp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetGamesRsp) + err := c.cc.Invoke(ctx, EveningDetectiveServer_GetGames_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *eveningDetectiveServerClient) GetGame(ctx context.Context, in *GetGameReq, opts ...grpc.CallOption) (*GetGameRsp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetGameRsp) + err := c.cc.Invoke(ctx, EveningDetectiveServer_GetGame_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *eveningDetectiveServerClient) UpdateGame(ctx context.Context, in *UpdateGameReq, opts ...grpc.CallOption) (*UpdateGameRsp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdateGameRsp) + err := c.cc.Invoke(ctx, EveningDetectiveServer_UpdateGame_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *eveningDetectiveServerClient) DeleteGame(ctx context.Context, in *DeleteGameReq, opts ...grpc.CallOption) (*DeleteGameRsp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeleteGameRsp) + err := c.cc.Invoke(ctx, EveningDetectiveServer_DeleteGame_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // EveningDetectiveServerServer is the server API for EveningDetectiveServer service. // All implementations must embed UnimplementedEveningDetectiveServerServer // for forward compatibility. @@ -378,6 +438,11 @@ type EveningDetectiveServerServer interface { AddScenarioPlace(context.Context, *AddScenarioPlaceReq) (*AddScenarioPlaceRsp, error) UpdateScenarioPlace(context.Context, *UpdateScenarioPlaceReq) (*UpdateScenarioPlaceRsp, error) DeleteScenarioPlace(context.Context, *DeleteScenarioPlaceReq) (*DeleteScenarioPlaceRsp, error) + AddGame(context.Context, *AddGameReq) (*AddGameRsp, error) + GetGames(context.Context, *GetGamesReq) (*GetGamesRsp, error) + GetGame(context.Context, *GetGameReq) (*GetGameRsp, error) + UpdateGame(context.Context, *UpdateGameReq) (*UpdateGameRsp, error) + DeleteGame(context.Context, *DeleteGameReq) (*DeleteGameRsp, error) mustEmbedUnimplementedEveningDetectiveServerServer() } @@ -466,6 +531,21 @@ func (UnimplementedEveningDetectiveServerServer) UpdateScenarioPlace(context.Con func (UnimplementedEveningDetectiveServerServer) DeleteScenarioPlace(context.Context, *DeleteScenarioPlaceReq) (*DeleteScenarioPlaceRsp, error) { return nil, status.Error(codes.Unimplemented, "method DeleteScenarioPlace not implemented") } +func (UnimplementedEveningDetectiveServerServer) AddGame(context.Context, *AddGameReq) (*AddGameRsp, error) { + return nil, status.Error(codes.Unimplemented, "method AddGame not implemented") +} +func (UnimplementedEveningDetectiveServerServer) GetGames(context.Context, *GetGamesReq) (*GetGamesRsp, error) { + return nil, status.Error(codes.Unimplemented, "method GetGames not implemented") +} +func (UnimplementedEveningDetectiveServerServer) GetGame(context.Context, *GetGameReq) (*GetGameRsp, error) { + return nil, status.Error(codes.Unimplemented, "method GetGame not implemented") +} +func (UnimplementedEveningDetectiveServerServer) UpdateGame(context.Context, *UpdateGameReq) (*UpdateGameRsp, error) { + return nil, status.Error(codes.Unimplemented, "method UpdateGame not implemented") +} +func (UnimplementedEveningDetectiveServerServer) DeleteGame(context.Context, *DeleteGameReq) (*DeleteGameRsp, error) { + return nil, status.Error(codes.Unimplemented, "method DeleteGame not implemented") +} func (UnimplementedEveningDetectiveServerServer) mustEmbedUnimplementedEveningDetectiveServerServer() { } func (UnimplementedEveningDetectiveServerServer) testEmbeddedByValue() {} @@ -956,6 +1036,96 @@ func _EveningDetectiveServer_DeleteScenarioPlace_Handler(srv interface{}, ctx co return interceptor(ctx, in, info, handler) } +func _EveningDetectiveServer_AddGame_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AddGameReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EveningDetectiveServerServer).AddGame(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: EveningDetectiveServer_AddGame_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EveningDetectiveServerServer).AddGame(ctx, req.(*AddGameReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _EveningDetectiveServer_GetGames_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetGamesReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EveningDetectiveServerServer).GetGames(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: EveningDetectiveServer_GetGames_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EveningDetectiveServerServer).GetGames(ctx, req.(*GetGamesReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _EveningDetectiveServer_GetGame_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetGameReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EveningDetectiveServerServer).GetGame(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: EveningDetectiveServer_GetGame_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EveningDetectiveServerServer).GetGame(ctx, req.(*GetGameReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _EveningDetectiveServer_UpdateGame_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateGameReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EveningDetectiveServerServer).UpdateGame(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: EveningDetectiveServer_UpdateGame_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EveningDetectiveServerServer).UpdateGame(ctx, req.(*UpdateGameReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _EveningDetectiveServer_DeleteGame_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteGameReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EveningDetectiveServerServer).DeleteGame(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: EveningDetectiveServer_DeleteGame_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EveningDetectiveServerServer).DeleteGame(ctx, req.(*DeleteGameReq)) + } + return interceptor(ctx, in, info, handler) +} + // EveningDetectiveServer_ServiceDesc is the grpc.ServiceDesc for EveningDetectiveServer service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -1067,6 +1237,26 @@ var EveningDetectiveServer_ServiceDesc = grpc.ServiceDesc{ MethodName: "DeleteScenarioPlace", Handler: _EveningDetectiveServer_DeleteScenarioPlace_Handler, }, + { + MethodName: "AddGame", + Handler: _EveningDetectiveServer_AddGame_Handler, + }, + { + MethodName: "GetGames", + Handler: _EveningDetectiveServer_GetGames_Handler, + }, + { + MethodName: "GetGame", + Handler: _EveningDetectiveServer_GetGame_Handler, + }, + { + MethodName: "UpdateGame", + Handler: _EveningDetectiveServer_UpdateGame_Handler, + }, + { + MethodName: "DeleteGame", + Handler: _EveningDetectiveServer_DeleteGame_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "main.proto",