This commit is contained in:
2026-09-10 03:51:22 +07:00
parent 3b85484701
commit d0c8700a7a
10 changed files with 1351 additions and 378 deletions
+50
View File
@@ -573,6 +573,25 @@ service EveningDetectiveServer {
};
}
rpc GetGameMap(GetGameMapReq) returns (GetGameMapRsp) {
option (google.api.http) = { get: "/api/games/{gameId}/map" };
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags : "Экраны";
summary: "Получить карту игры";
};
}
rpc UpdateGameMapItem(UpdateGameMapItemReq) returns (UpdateGameMapItemRsp) {
option (google.api.http) = {
post: "/api/games/{gameId}/map/items/{kind}/{itemId}"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags : "Экраны";
summary: "Изменить объект карты игры";
};
}
// Изменить общий режим показа всех экранов игры.
rpc SetScreenMode(SetScreenModeReq) returns (SetScreenModeRsp) {
option (google.api.http) = {
@@ -1354,6 +1373,37 @@ message SetScreenSoundRsp {
string error = 1;
}
message MapItem {
string kind = 1;
int32 item_id = 2;
string label = 3;
int32 x = 4;
int32 y = 5;
bool hidden = 6;
string status = 7;
bool sound_enabled = 8;
}
message GetGameMapReq {
int32 gameId = 1;
}
message GetGameMapRsp {
string error = 1;
repeated MapItem items = 2;
}
message UpdateGameMapItemReq {
int32 gameId = 1;
string kind = 2;
int32 itemId = 3;
int32 x = 4;
int32 y = 5;
bool hidden = 6;
}
message UpdateGameMapItemRsp { string error = 1; }
message SetScreenModeReq {
int32 gameId = 1;
ScreenMode mode = 2;
Binary file not shown.
+3
View File
@@ -16,6 +16,7 @@ import (
"evening_detective_server/internal/modules/team_qr_pdf"
"evening_detective_server/internal/repos/actions_repo"
"evening_detective_server/internal/repos/applications_repo"
"evening_detective_server/internal/repos/game_map_repo"
"evening_detective_server/internal/repos/games_repo"
"evening_detective_server/internal/repos/refresh_tokens_repo"
"evening_detective_server/internal/repos/scenarios_repo"
@@ -130,6 +131,7 @@ func main() {
applicationsRepo := applications_repo.NewApplicationsRepo(dbpool)
answersRepo := team_answers_repo.NewTeamAnswersRepo(dbpool)
screenRepo := screen_sessions_repo.NewScreenSessionsRepo(dbpool)
mapRepo := game_map_repo.New(dbpool)
gameService := game_service.NewGameService(
gameRepo,
teamRepo,
@@ -191,6 +193,7 @@ func main() {
scenarioService,
gameService,
screenRepo,
mapRepo,
),
)
@@ -388,6 +388,91 @@
]
}
},
"/api/games/{gameId}/map": {
"get": {
"summary": "Получить карту игры",
"operationId": "EveningDetectiveServer_GetGameMap",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/evening_detective_serverGetGameMapRsp"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "gameId",
"in": "path",
"required": true,
"type": "integer",
"format": "int32"
}
],
"tags": [
"Экраны"
]
}
},
"/api/games/{gameId}/map/items/{kind}/{itemId}": {
"post": {
"summary": "Изменить объект карты игры",
"operationId": "EveningDetectiveServer_UpdateGameMapItem",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/evening_detective_serverUpdateGameMapItemRsp"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "gameId",
"in": "path",
"required": true,
"type": "integer",
"format": "int32"
},
{
"name": "kind",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "itemId",
"in": "path",
"required": true,
"type": "integer",
"format": "int32"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/EveningDetectiveServerUpdateGameMapItemBody"
}
}
],
"tags": [
"Экраны"
]
}
},
"/api/games/{gameId}/results": {
"get": {
"summary": "Получить итоговую таблицу игры (после завершения)",
@@ -2655,6 +2740,22 @@
}
}
},
"EveningDetectiveServerUpdateGameMapItemBody": {
"type": "object",
"properties": {
"x": {
"type": "integer",
"format": "int32"
},
"y": {
"type": "integer",
"format": "int32"
},
"hidden": {
"type": "boolean"
}
}
},
"EveningDetectiveServerUpdateScenarioBackgroundBody": {
"type": "object",
"properties": {
@@ -3117,6 +3218,21 @@
}
}
},
"evening_detective_serverGetGameMapRsp": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"items": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/evening_detective_serverMapItem"
}
}
}
},
"evening_detective_serverGetGameResultsRsp": {
"type": "object",
"properties": {
@@ -3404,6 +3520,38 @@
}
}
},
"evening_detective_serverMapItem": {
"type": "object",
"properties": {
"kind": {
"type": "string"
},
"itemId": {
"type": "integer",
"format": "int32"
},
"label": {
"type": "string"
},
"x": {
"type": "integer",
"format": "int32"
},
"y": {
"type": "integer",
"format": "int32"
},
"hidden": {
"type": "boolean"
},
"status": {
"type": "string"
},
"soundEnabled": {
"type": "boolean"
}
}
},
"evening_detective_serverPauseGameRsp": {
"type": "object",
"properties": {
@@ -3843,6 +3991,14 @@
}
}
},
"evening_detective_serverUpdateGameMapItemRsp": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
},
"evening_detective_serverUpdateGameRsp": {
"type": "object",
"properties": {
+70
View File
@@ -17,6 +17,7 @@ import (
"evening_detective_server/internal/modules/roles"
"evening_detective_server/internal/modules/scenario_archive"
"evening_detective_server/internal/modules/string_tools"
"evening_detective_server/internal/repos/game_map_repo"
"evening_detective_server/internal/repos/scenarios_repo"
"evening_detective_server/internal/repos/screen_sessions_repo"
"evening_detective_server/internal/repos/users_repo"
@@ -47,6 +48,7 @@ type server struct {
scenarioService *scenarios_service.ScenarioService
gameService *game_service.GameService
screenRepo *screen_sessions_repo.ScreenSessionsRepo
mapRepo *game_map_repo.Repo
}
func NewServer(
@@ -56,6 +58,7 @@ func NewServer(
scenarioService *scenarios_service.ScenarioService,
gameService *game_service.GameService,
screenRepo *screen_sessions_repo.ScreenSessionsRepo,
mapRepo *game_map_repo.Repo,
) proto.EveningDetectiveServerServer {
return &server{
usersService: usersService,
@@ -64,6 +67,7 @@ func NewServer(
scenarioService: scenarioService,
gameService: gameService,
screenRepo: screenRepo,
mapRepo: mapRepo,
}
}
@@ -183,6 +187,72 @@ func (s *server) SetScreenSound(ctx context.Context, req *proto.SetScreenSoundRe
return &proto.SetScreenSoundRsp{}, nil
}
func (s *server) GetGameMap(ctx context.Context, req *proto.GetGameMapReq) (*proto.GetGameMapRsp, error) {
if !canManageScreens(ctx) {
return nil, status.Error(codes.PermissionDenied, "permission denied")
}
if req == nil || req.GameId <= 0 {
return nil, status.Error(codes.InvalidArgument, "некорректный идентификатор игры")
}
game, err := s.gameService.GetFullGame(ctx, int(req.GameId))
if err != nil {
return nil, status.Error(codes.NotFound, "игра не найдена")
}
for _, team := range game.Teams {
if err := s.mapRepo.Ensure(ctx, int(req.GameId), "team", team.ID); err != nil {
return nil, status.Error(codes.Internal, "не удалось сохранить карту")
}
}
screens, err := s.screenRepo.ListByGame(ctx, int(req.GameId))
if err != nil {
return nil, status.Error(codes.Internal, "не удалось получить экраны")
}
for _, screen := range screens {
if err := s.mapRepo.Ensure(ctx, int(req.GameId), "screen", screen.ID); err != nil {
return nil, status.Error(codes.Internal, "не удалось сохранить карту")
}
}
items, err := s.mapRepo.List(ctx, int(req.GameId))
if err != nil {
return nil, status.Error(codes.Internal, "не удалось получить карту")
}
teamNames := map[int]string{}
for _, team := range game.Teams {
teamNames[team.ID] = team.Name
}
screenStates := map[int]*proto.ScreenState{}
for _, screen := range screens {
screenStates[screen.ID] = screenState(screen)
}
result := make([]*proto.MapItem, 0, len(items))
for _, item := range items {
mapped := &proto.MapItem{Kind: item.Kind, ItemId: int32(item.ItemID), X: int32(item.X), Y: int32(item.Y), Hidden: item.Hidden}
if item.Kind == "team" {
mapped.Label = teamNames[item.ItemID]
}
if state := screenStates[item.ItemID]; item.Kind == "screen" && state != nil {
mapped.Label = "Экран " + state.Id
mapped.Status = state.Status
mapped.SoundEnabled = state.SoundEnabled
}
result = append(result, mapped)
}
return &proto.GetGameMapRsp{Items: result}, nil
}
func (s *server) UpdateGameMapItem(ctx context.Context, req *proto.UpdateGameMapItemReq) (*proto.UpdateGameMapItemRsp, error) {
if !canManageScreens(ctx) {
return nil, status.Error(codes.PermissionDenied, "permission denied")
}
if req == nil || req.GameId <= 0 || req.ItemId <= 0 || (req.Kind != "team" && req.Kind != "screen") {
return nil, status.Error(codes.InvalidArgument, "некорректный объект карты")
}
if err := s.mapRepo.Update(ctx, game_map_repo.Item{GameID: int(req.GameId), Kind: req.Kind, ItemID: int(req.ItemId), X: int(req.X), Y: int(req.Y), Hidden: req.Hidden}); err != nil {
return nil, status.Error(codes.Internal, "не удалось изменить карту")
}
return &proto.UpdateGameMapItemRsp{}, nil
}
func canManageScreens(ctx context.Context) bool {
claims, ok := ctx.Value("claims").(*processor_jwt.JWTClaims)
if !ok || claims == nil {
+53
View File
@@ -0,0 +1,53 @@
package game_map_repo
import (
"context"
"github.com/jackc/pgx/v5/pgxpool"
)
type Item struct {
GameID int
Kind string
ItemID int
X int
Y int
Hidden bool
}
type Repo struct{
pool *pgxpool.Pool
}
func New(pool *pgxpool.Pool) *Repo {
return &Repo{pool: pool}
}
func (r *Repo) Ensure(ctx context.Context, gameID int, kind string, itemID int) error {
_, err := r.pool.Exec(ctx, `
INSERT INTO game_map_items (game_id, kind, item_id)
VALUES ($1, $2, $3) ON CONFLICT (game_id, kind, item_id) DO NOTHING`, gameID, kind, itemID)
return err
}
func (r *Repo) List(ctx context.Context, gameID int) ([]Item, error) {
rows, err := r.pool.Query(ctx, `SELECT game_id, kind, item_id, x, y, hidden FROM game_map_items WHERE game_id = $1 ORDER BY kind, item_id`, gameID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Item
for rows.Next() {
var item Item
if err := rows.Scan(&item.GameID, &item.Kind, &item.ItemID, &item.X, &item.Y, &item.Hidden); err != nil {
return nil, err
}
items = append(items, item)
}
return items, rows.Err()
}
func (r *Repo) Update(ctx context.Context, item Item) error {
_, err := r.pool.Exec(ctx, `UPDATE game_map_items SET x = $4, y = $5, hidden = $6 WHERE game_id = $1 AND kind = $2 AND item_id = $3`, item.GameID, item.Kind, item.ItemID, item.X, item.Y, item.Hidden)
return err
}
@@ -0,0 +1,9 @@
CREATE TABLE game_map_items (
game_id INTEGER NOT NULL REFERENCES games(id) ON DELETE CASCADE,
kind TEXT NOT NULL,
item_id INTEGER NOT NULL,
x INTEGER NOT NULL DEFAULT 40,
y INTEGER NOT NULL DEFAULT 40,
hidden BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY (game_id, kind, item_id)
);
+740 -378
View File
File diff suppressed because it is too large Load Diff
+194
View File
@@ -1746,6 +1746,122 @@ func local_request_EveningDetectiveServer_SetScreenSound_0(ctx context.Context,
return msg, metadata, err
}
func request_EveningDetectiveServer_GetGameMap_0(ctx context.Context, marshaler runtime.Marshaler, client EveningDetectiveServerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetGameMapReq
metadata runtime.ServerMetadata
err error
)
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
val, ok := pathParams["gameId"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "gameId")
}
protoReq.GameId, err = runtime.Int32(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "gameId", err)
}
msg, err := client.GetGameMap(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_EveningDetectiveServer_GetGameMap_0(ctx context.Context, marshaler runtime.Marshaler, server EveningDetectiveServerServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetGameMapReq
metadata runtime.ServerMetadata
err error
)
val, ok := pathParams["gameId"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "gameId")
}
protoReq.GameId, err = runtime.Int32(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "gameId", err)
}
msg, err := server.GetGameMap(ctx, &protoReq)
return msg, metadata, err
}
func request_EveningDetectiveServer_UpdateGameMapItem_0(ctx context.Context, marshaler runtime.Marshaler, client EveningDetectiveServerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq UpdateGameMapItemReq
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["gameId"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "gameId")
}
protoReq.GameId, err = runtime.Int32(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "gameId", err)
}
val, ok = pathParams["kind"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "kind")
}
protoReq.Kind, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "kind", err)
}
val, ok = pathParams["itemId"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "itemId")
}
protoReq.ItemId, err = runtime.Int32(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "itemId", err)
}
msg, err := client.UpdateGameMapItem(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_EveningDetectiveServer_UpdateGameMapItem_0(ctx context.Context, marshaler runtime.Marshaler, server EveningDetectiveServerServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq UpdateGameMapItemReq
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["gameId"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "gameId")
}
protoReq.GameId, err = runtime.Int32(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "gameId", err)
}
val, ok = pathParams["kind"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "kind")
}
protoReq.Kind, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "kind", err)
}
val, ok = pathParams["itemId"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "itemId")
}
protoReq.ItemId, err = runtime.Int32(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "itemId", err)
}
msg, err := server.UpdateGameMapItem(ctx, &protoReq)
return msg, metadata, err
}
func request_EveningDetectiveServer_SetScreenMode_0(ctx context.Context, marshaler runtime.Marshaler, client EveningDetectiveServerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq SetScreenModeReq
@@ -3680,6 +3796,46 @@ func RegisterEveningDetectiveServerHandlerServer(ctx context.Context, mux *runti
}
forward_EveningDetectiveServer_SetScreenSound_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodGet, pattern_EveningDetectiveServer_GetGameMap_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/GetGameMap", runtime.WithHTTPPathPattern("/api/games/{gameId}/map"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_EveningDetectiveServer_GetGameMap_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_GetGameMap_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_EveningDetectiveServer_UpdateGameMapItem_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/UpdateGameMapItem", runtime.WithHTTPPathPattern("/api/games/{gameId}/map/items/{kind}/{itemId}"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_EveningDetectiveServer_UpdateGameMapItem_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_UpdateGameMapItem_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_EveningDetectiveServer_SetScreenMode_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@@ -4976,6 +5132,40 @@ func RegisterEveningDetectiveServerHandlerClient(ctx context.Context, mux *runti
}
forward_EveningDetectiveServer_SetScreenSound_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodGet, pattern_EveningDetectiveServer_GetGameMap_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/GetGameMap", runtime.WithHTTPPathPattern("/api/games/{gameId}/map"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_EveningDetectiveServer_GetGameMap_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_GetGameMap_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_EveningDetectiveServer_UpdateGameMapItem_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/UpdateGameMapItem", runtime.WithHTTPPathPattern("/api/games/{gameId}/map/items/{kind}/{itemId}"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_EveningDetectiveServer_UpdateGameMapItem_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_UpdateGameMapItem_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_EveningDetectiveServer_SetScreenMode_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@@ -5402,6 +5592,8 @@ var (
pattern_EveningDetectiveServer_BindScreen_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"api", "screens", "screenId", "bind"}, ""))
pattern_EveningDetectiveServer_UnbindScreen_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"api", "screens", "screenId", "unbind"}, ""))
pattern_EveningDetectiveServer_SetScreenSound_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"api", "screens", "screenId", "sound"}, ""))
pattern_EveningDetectiveServer_GetGameMap_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"api", "games", "gameId", "map"}, ""))
pattern_EveningDetectiveServer_UpdateGameMapItem_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 1, 0, 4, 1, 5, 6}, []string{"api", "games", "gameId", "map", "items", "kind", "itemId"}, ""))
pattern_EveningDetectiveServer_SetScreenMode_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 2, 4}, []string{"api", "games", "gameId", "screens", "mode"}, ""))
pattern_EveningDetectiveServer_SendScreenCommand_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 2, 4}, []string{"api", "games", "gameId", "screens", "command"}, ""))
pattern_EveningDetectiveServer_DownloadTeamQR_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 2, 4}, []string{"api", "games", "id", "teams", "qr.pdf"}, ""))
@@ -5475,6 +5667,8 @@ var (
forward_EveningDetectiveServer_BindScreen_0 = runtime.ForwardResponseMessage
forward_EveningDetectiveServer_UnbindScreen_0 = runtime.ForwardResponseMessage
forward_EveningDetectiveServer_SetScreenSound_0 = runtime.ForwardResponseMessage
forward_EveningDetectiveServer_GetGameMap_0 = runtime.ForwardResponseMessage
forward_EveningDetectiveServer_UpdateGameMapItem_0 = runtime.ForwardResponseMessage
forward_EveningDetectiveServer_SetScreenMode_0 = runtime.ForwardResponseMessage
forward_EveningDetectiveServer_SendScreenCommand_0 = runtime.ForwardResponseMessage
forward_EveningDetectiveServer_DownloadTeamQR_0 = runtime.ForwardResponseMessage
+76
View File
@@ -68,6 +68,8 @@ const (
EveningDetectiveServer_BindScreen_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/BindScreen"
EveningDetectiveServer_UnbindScreen_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/UnbindScreen"
EveningDetectiveServer_SetScreenSound_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/SetScreenSound"
EveningDetectiveServer_GetGameMap_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/GetGameMap"
EveningDetectiveServer_UpdateGameMapItem_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/UpdateGameMapItem"
EveningDetectiveServer_SetScreenMode_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/SetScreenMode"
EveningDetectiveServer_SendScreenCommand_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/SendScreenCommand"
EveningDetectiveServer_DownloadTeamQR_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/DownloadTeamQR"
@@ -152,6 +154,8 @@ type EveningDetectiveServerClient interface {
// Отвязать экран от игры. Требует авторизацию организатора, автора или администратора.
UnbindScreen(ctx context.Context, in *UnbindScreenReq, opts ...grpc.CallOption) (*UnbindScreenRsp, error)
SetScreenSound(ctx context.Context, in *SetScreenSoundReq, opts ...grpc.CallOption) (*SetScreenSoundRsp, error)
GetGameMap(ctx context.Context, in *GetGameMapReq, opts ...grpc.CallOption) (*GetGameMapRsp, error)
UpdateGameMapItem(ctx context.Context, in *UpdateGameMapItemReq, opts ...grpc.CallOption) (*UpdateGameMapItemRsp, error)
// Изменить общий режим показа всех экранов игры.
SetScreenMode(ctx context.Context, in *SetScreenModeReq, opts ...grpc.CallOption) (*SetScreenModeRsp, error)
// Отправить общую команду экранам игры.
@@ -666,6 +670,26 @@ func (c *eveningDetectiveServerClient) SetScreenSound(ctx context.Context, in *S
return out, nil
}
func (c *eveningDetectiveServerClient) GetGameMap(ctx context.Context, in *GetGameMapReq, opts ...grpc.CallOption) (*GetGameMapRsp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetGameMapRsp)
err := c.cc.Invoke(ctx, EveningDetectiveServer_GetGameMap_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *eveningDetectiveServerClient) UpdateGameMapItem(ctx context.Context, in *UpdateGameMapItemReq, opts ...grpc.CallOption) (*UpdateGameMapItemRsp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(UpdateGameMapItemRsp)
err := c.cc.Invoke(ctx, EveningDetectiveServer_UpdateGameMapItem_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *eveningDetectiveServerClient) SetScreenMode(ctx context.Context, in *SetScreenModeReq, opts ...grpc.CallOption) (*SetScreenModeRsp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(SetScreenModeRsp)
@@ -946,6 +970,8 @@ type EveningDetectiveServerServer interface {
// Отвязать экран от игры. Требует авторизацию организатора, автора или администратора.
UnbindScreen(context.Context, *UnbindScreenReq) (*UnbindScreenRsp, error)
SetScreenSound(context.Context, *SetScreenSoundReq) (*SetScreenSoundRsp, error)
GetGameMap(context.Context, *GetGameMapReq) (*GetGameMapRsp, error)
UpdateGameMapItem(context.Context, *UpdateGameMapItemReq) (*UpdateGameMapItemRsp, error)
// Изменить общий режим показа всех экранов игры.
SetScreenMode(context.Context, *SetScreenModeReq) (*SetScreenModeRsp, error)
// Отправить общую команду экранам игры.
@@ -1124,6 +1150,12 @@ func (UnimplementedEveningDetectiveServerServer) UnbindScreen(context.Context, *
func (UnimplementedEveningDetectiveServerServer) SetScreenSound(context.Context, *SetScreenSoundReq) (*SetScreenSoundRsp, error) {
return nil, status.Error(codes.Unimplemented, "method SetScreenSound not implemented")
}
func (UnimplementedEveningDetectiveServerServer) GetGameMap(context.Context, *GetGameMapReq) (*GetGameMapRsp, error) {
return nil, status.Error(codes.Unimplemented, "method GetGameMap not implemented")
}
func (UnimplementedEveningDetectiveServerServer) UpdateGameMapItem(context.Context, *UpdateGameMapItemReq) (*UpdateGameMapItemRsp, error) {
return nil, status.Error(codes.Unimplemented, "method UpdateGameMapItem not implemented")
}
func (UnimplementedEveningDetectiveServerServer) SetScreenMode(context.Context, *SetScreenModeReq) (*SetScreenModeRsp, error) {
return nil, status.Error(codes.Unimplemented, "method SetScreenMode not implemented")
}
@@ -2076,6 +2108,42 @@ func _EveningDetectiveServer_SetScreenSound_Handler(srv interface{}, ctx context
return interceptor(ctx, in, info, handler)
}
func _EveningDetectiveServer_GetGameMap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetGameMapReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(EveningDetectiveServerServer).GetGameMap(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: EveningDetectiveServer_GetGameMap_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(EveningDetectiveServerServer).GetGameMap(ctx, req.(*GetGameMapReq))
}
return interceptor(ctx, in, info, handler)
}
func _EveningDetectiveServer_UpdateGameMapItem_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateGameMapItemReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(EveningDetectiveServerServer).UpdateGameMapItem(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: EveningDetectiveServer_UpdateGameMapItem_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(EveningDetectiveServerServer).UpdateGameMapItem(ctx, req.(*UpdateGameMapItemReq))
}
return interceptor(ctx, in, info, handler)
}
func _EveningDetectiveServer_SetScreenMode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SetScreenModeReq)
if err := dec(in); err != nil {
@@ -2671,6 +2739,14 @@ var EveningDetectiveServer_ServiceDesc = grpc.ServiceDesc{
MethodName: "SetScreenSound",
Handler: _EveningDetectiveServer_SetScreenSound_Handler,
},
{
MethodName: "GetGameMap",
Handler: _EveningDetectiveServer_GetGameMap_Handler,
},
{
MethodName: "UpdateGameMapItem",
Handler: _EveningDetectiveServer_UpdateGameMapItem_Handler,
},
{
MethodName: "SetScreenMode",
Handler: _EveningDetectiveServer_SetScreenMode_Handler,