generated from VLADIMIR/template
add teams operations
This commit is contained in:
+49
-7
@@ -544,8 +544,20 @@ func (s *server) AddTeam(ctx context.Context, req *proto.AddTeamReq) (*proto.Add
|
||||
if !roles.HasRole(claims, roles.Organizer) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
|
||||
panic("unimplemented")
|
||||
|
||||
err := s.gameService.AddTeam(
|
||||
ctx,
|
||||
claims.UserID,
|
||||
int(req.GameId),
|
||||
req.Name,
|
||||
)
|
||||
if err != nil {
|
||||
return &proto.AddTeamRsp{
|
||||
Error: err.Error(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
return &proto.AddTeamRsp{}, nil
|
||||
}
|
||||
|
||||
func (s *server) UpdateTeam(ctx context.Context, req *proto.UpdateTeamReq) (*proto.UpdateTeamRsp, error) {
|
||||
@@ -553,8 +565,19 @@ func (s *server) UpdateTeam(ctx context.Context, req *proto.UpdateTeamReq) (*pro
|
||||
if !roles.HasRole(claims, roles.Organizer) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
|
||||
panic("unimplemented")
|
||||
|
||||
err := s.gameService.UpdateTeam(
|
||||
ctx,
|
||||
int(req.Id),
|
||||
req.Name,
|
||||
)
|
||||
if err != nil {
|
||||
return &proto.UpdateTeamRsp{
|
||||
Error: err.Error(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
return &proto.UpdateTeamRsp{}, nil
|
||||
}
|
||||
|
||||
func (s *server) DeleteTeam(ctx context.Context, req *proto.DeleteTeamReq) (*proto.DeleteTeamRsp, error) {
|
||||
@@ -562,8 +585,18 @@ func (s *server) DeleteTeam(ctx context.Context, req *proto.DeleteTeamReq) (*pro
|
||||
if !roles.HasRole(claims, roles.Organizer) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
|
||||
panic("unimplemented")
|
||||
|
||||
err := s.gameService.DeleteTeam(
|
||||
ctx,
|
||||
int(req.Id),
|
||||
)
|
||||
if err != nil {
|
||||
return &proto.DeleteTeamRsp{
|
||||
Error: err.Error(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
return &proto.DeleteTeamRsp{}, nil
|
||||
}
|
||||
|
||||
func (s *server) GiveTeamApplications(ctx context.Context, req *proto.GiveTeamApplicationsReq) (*proto.GiveTeamApplicationsRsp, error) {
|
||||
@@ -571,7 +604,7 @@ func (s *server) GiveTeamApplications(ctx context.Context, req *proto.GiveTeamAp
|
||||
if !roles.HasRole(claims, roles.Organizer) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
|
||||
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
@@ -582,3 +615,12 @@ func (s *server) GetTeamActions(ctx context.Context, req *proto.GetTeamActionsRe
|
||||
func (s *server) AddTeamAction(ctx context.Context, req *proto.AddTeamActionReq) (*proto.AddTeamActionRsp, error) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (s *server) DeleteLastTeamAction(ctx context.Context, req *proto.DeleteLastTeamActionReq) (*proto.DeleteLastTeamActionRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
if !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
@@ -9,8 +9,10 @@ func mapTeam(
|
||||
o *game_service.Team,
|
||||
) *proto.Team {
|
||||
return &proto.Team{
|
||||
Id: int32(o.ID),
|
||||
Name: o.Name,
|
||||
Id: int32(o.ID),
|
||||
Name: o.Name,
|
||||
Status: o.Status,
|
||||
Password: o.Password,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user