generated from VLADIMIR/template
add cover
This commit is contained in:
@@ -1316,6 +1316,8 @@ message ScreenState {
|
||||
string error = 6;
|
||||
int64 state_version = 7;
|
||||
int64 position_ms = 8;
|
||||
string game_name = 9;
|
||||
string cover_image = 10;
|
||||
}
|
||||
|
||||
message CreateScreenSessionReq {}
|
||||
|
||||
Binary file not shown.
@@ -3791,6 +3791,12 @@
|
||||
"positionMs": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"gameName": {
|
||||
"type": "string"
|
||||
},
|
||||
"coverImage": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+20
-2
@@ -95,7 +95,9 @@ func (s *server) GetScreenState(ctx context.Context, req *proto.GetScreenStateRe
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, "не удалось получить состояние экрана")
|
||||
}
|
||||
return &proto.GetScreenStateRsp{State: screenState(session)}, nil
|
||||
state := screenState(session)
|
||||
s.enrichScreenState(ctx, session, state)
|
||||
return &proto.GetScreenStateRsp{State: state}, nil
|
||||
}
|
||||
|
||||
func (s *server) GetGameScreens(ctx context.Context, req *proto.GetGameScreensReq) (*proto.GetGameScreensRsp, error) {
|
||||
@@ -144,7 +146,9 @@ func (s *server) BindScreen(ctx context.Context, req *proto.BindScreenReq) (*pro
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, "не удалось получить состояние экрана")
|
||||
}
|
||||
return &proto.BindScreenRsp{State: screenState(session)}, nil
|
||||
state := screenState(session)
|
||||
s.enrichScreenState(ctx, session, state)
|
||||
return &proto.BindScreenRsp{State: state}, nil
|
||||
}
|
||||
|
||||
func (s *server) UnbindScreen(ctx context.Context, req *proto.UnbindScreenReq) (*proto.UnbindScreenRsp, error) {
|
||||
@@ -291,6 +295,20 @@ func screenState(session *screen_sessions_repo.ScreenSession) *proto.ScreenState
|
||||
return state
|
||||
}
|
||||
|
||||
func (s *server) enrichScreenState(ctx context.Context, session *screen_sessions_repo.ScreenSession, state *proto.ScreenState) {
|
||||
if session.GameID == nil {
|
||||
return
|
||||
}
|
||||
game, err := s.gameService.GetFullGame(ctx, *session.GameID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
state.GameName = game.Name
|
||||
if game.Scenario != nil && game.Scenario.Image != nil {
|
||||
state.CoverImage = *game.Scenario.Image
|
||||
}
|
||||
}
|
||||
|
||||
func (s *server) SetScreenMode(ctx context.Context, req *proto.SetScreenModeReq) (*proto.SetScreenModeRsp, error) {
|
||||
if !canManageScreens(ctx) {
|
||||
return nil, status.Error(codes.PermissionDenied, "permission denied")
|
||||
|
||||
+22
-2
@@ -4707,6 +4707,8 @@ type ScreenState struct {
|
||||
Error string `protobuf:"bytes,6,opt,name=error,proto3" json:"error,omitempty"`
|
||||
StateVersion int64 `protobuf:"varint,7,opt,name=state_version,json=stateVersion,proto3" json:"state_version,omitempty"`
|
||||
PositionMs int64 `protobuf:"varint,8,opt,name=position_ms,json=positionMs,proto3" json:"position_ms,omitempty"`
|
||||
GameName string `protobuf:"bytes,9,opt,name=game_name,json=gameName,proto3" json:"game_name,omitempty"`
|
||||
CoverImage string `protobuf:"bytes,10,opt,name=cover_image,json=coverImage,proto3" json:"cover_image,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -4797,6 +4799,20 @@ func (x *ScreenState) GetPositionMs() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ScreenState) GetGameName() string {
|
||||
if x != nil {
|
||||
return x.GameName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ScreenState) GetCoverImage() string {
|
||||
if x != nil {
|
||||
return x.CoverImage
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type CreateScreenSessionReq struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
@@ -8540,7 +8556,7 @@ const file_main_proto_rawDesc = "" +
|
||||
"started_at\x18\b \x01(\v2\x1a.google.protobuf.TimestampH\x00R\tstartedAt\x88\x01\x01\x12:\n" +
|
||||
"\bended_at\x18\t \x01(\v2\x1a.google.protobuf.TimestampH\x01R\aendedAt\x88\x01\x01B\r\n" +
|
||||
"\v_started_atB\v\n" +
|
||||
"\t_ended_at\"\xa0\x02\n" +
|
||||
"\t_ended_at\"\xde\x02\n" +
|
||||
"\vScreenState\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\tR\x02id\x12\x16\n" +
|
||||
"\x06status\x18\x02 \x01(\tR\x06status\x12\x1c\n" +
|
||||
@@ -8550,7 +8566,11 @@ const file_main_proto_rawDesc = "" +
|
||||
"\x05error\x18\x06 \x01(\tR\x05error\x12#\n" +
|
||||
"\rstate_version\x18\a \x01(\x03R\fstateVersion\x12\x1f\n" +
|
||||
"\vposition_ms\x18\b \x01(\x03R\n" +
|
||||
"positionMsB\n" +
|
||||
"positionMs\x12\x1b\n" +
|
||||
"\tgame_name\x18\t \x01(\tR\bgameName\x12\x1f\n" +
|
||||
"\vcover_image\x18\n" +
|
||||
" \x01(\tR\n" +
|
||||
"coverImageB\n" +
|
||||
"\n" +
|
||||
"\b_game_id\"\x18\n" +
|
||||
"\x16CreateScreenSessionReq\"n\n" +
|
||||
|
||||
Reference in New Issue
Block a user