generated from VLADIMIR/template
fix add team
This commit is contained in:
@@ -790,6 +790,8 @@ message AddTeamReq {
|
|||||||
|
|
||||||
message AddTeamRsp {
|
message AddTeamRsp {
|
||||||
string error = 1;
|
string error = 1;
|
||||||
|
int32 id = 2;
|
||||||
|
string password = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message UpdateTeamReq {
|
message UpdateTeamReq {
|
||||||
|
|||||||
Binary file not shown.
@@ -1514,6 +1514,13 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"error": {
|
"error": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"password": {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -545,7 +545,7 @@ func (s *server) AddTeam(ctx context.Context, req *proto.AddTeamReq) (*proto.Add
|
|||||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||||
}
|
}
|
||||||
|
|
||||||
err := s.gameService.AddTeam(
|
team, err := s.gameService.AddTeam(
|
||||||
ctx,
|
ctx,
|
||||||
claims.UserID,
|
claims.UserID,
|
||||||
int(req.GameId),
|
int(req.GameId),
|
||||||
@@ -557,7 +557,10 @@ func (s *server) AddTeam(ctx context.Context, req *proto.AddTeamReq) (*proto.Add
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return &proto.AddTeamRsp{}, nil
|
return &proto.AddTeamRsp{
|
||||||
|
Id: int32(team.ID),
|
||||||
|
Password: team.Password,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *server) UpdateTeam(ctx context.Context, req *proto.UpdateTeamReq) (*proto.UpdateTeamRsp, error) {
|
func (s *server) UpdateTeam(ctx context.Context, req *proto.UpdateTeamReq) (*proto.UpdateTeamRsp, error) {
|
||||||
|
|||||||
@@ -144,17 +144,23 @@ func (s *GameService) AddTeam(
|
|||||||
creatorId int,
|
creatorId int,
|
||||||
gameId int,
|
gameId int,
|
||||||
name string,
|
name string,
|
||||||
) error {
|
) (*Team, error) {
|
||||||
game, err := s.gamesRepo.GetGameByID(ctx, gameId)
|
game, err := s.gamesRepo.GetGameByID(ctx, gameId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
password, err := s.passwordGenerator.Generate()
|
password, err := s.passwordGenerator.Generate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
_, err = s.teamsRepo.AddTeam(ctx, creatorId, gameId, name, game.ScenarioId, password)
|
id, err := s.teamsRepo.AddTeam(ctx, creatorId, gameId, name, game.ScenarioId, password)
|
||||||
return err
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &Team{
|
||||||
|
ID: id,
|
||||||
|
Password: password,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *GameService) UpdateTeam(ctx context.Context, teamId int, name string) error {
|
func (s *GameService) UpdateTeam(ctx context.Context, teamId int, name string) error {
|
||||||
|
|||||||
+20
-2
@@ -3568,6 +3568,8 @@ func (x *AddTeamReq) GetName() string {
|
|||||||
type AddTeamRsp struct {
|
type AddTeamRsp struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"`
|
Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"`
|
||||||
|
Id int32 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
|
Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"`
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
}
|
}
|
||||||
@@ -3609,6 +3611,20 @@ func (x *AddTeamRsp) GetError() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *AddTeamRsp) GetId() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Id
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *AddTeamRsp) GetPassword() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Password
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
type UpdateTeamReq struct {
|
type UpdateTeamReq struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
@@ -4407,10 +4423,12 @@ const file_main_proto_rawDesc = "" +
|
|||||||
"\n" +
|
"\n" +
|
||||||
"AddTeamReq\x12\x17\n" +
|
"AddTeamReq\x12\x17\n" +
|
||||||
"\agame_id\x18\x01 \x01(\x05R\x06gameId\x12\x12\n" +
|
"\agame_id\x18\x01 \x01(\x05R\x06gameId\x12\x12\n" +
|
||||||
"\x04name\x18\x02 \x01(\tR\x04name\"\"\n" +
|
"\x04name\x18\x02 \x01(\tR\x04name\"N\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"AddTeamRsp\x12\x14\n" +
|
"AddTeamRsp\x12\x14\n" +
|
||||||
"\x05error\x18\x01 \x01(\tR\x05error\"3\n" +
|
"\x05error\x18\x01 \x01(\tR\x05error\x12\x0e\n" +
|
||||||
|
"\x02id\x18\x02 \x01(\x05R\x02id\x12\x1a\n" +
|
||||||
|
"\bpassword\x18\x03 \x01(\tR\bpassword\"3\n" +
|
||||||
"\rUpdateTeamReq\x12\x0e\n" +
|
"\rUpdateTeamReq\x12\x0e\n" +
|
||||||
"\x02id\x18\x01 \x01(\x05R\x02id\x12\x12\n" +
|
"\x02id\x18\x01 \x01(\x05R\x02id\x12\x12\n" +
|
||||||
"\x04name\x18\x02 \x01(\tR\x04name\"%\n" +
|
"\x04name\x18\x02 \x01(\tR\x04name\"%\n" +
|
||||||
|
|||||||
Reference in New Issue
Block a user