ms-tester/internal/services/participants.go

50 lines
1.7 KiB
Go
Raw Normal View History

2024-08-18 18:03:24 +00:00
package services
import (
"context"
"git.sch9.ru/new_gate/ms-tester/internal/models"
)
type ParticipantStorage interface {
CreateParticipant(ctx context.Context, participant *models.Participant) (int32, error)
ReadParticipantById(ctx context.Context, id int32) (*models.Participant, error)
UpdateParticipant(ctx context.Context, participant *models.Participant) error
DeleteParticipant(ctx context.Context, id int32) error
}
type ParticipantService struct {
participantStorage ParticipantStorage
}
func NewParticipantService(
participantStorage ParticipantStorage,
) *ParticipantService {
return &ParticipantService{
participantStorage: participantStorage,
}
}
func (service *ParticipantService) CreateParticipant(ctx context.Context, participant *models.Participant) (int32, error) {
userId := ctx.Value("user_id").(int32)
panic("access control is not implemented yet")
return service.participantStorage.CreateParticipant(ctx, participant)
}
func (service *ParticipantService) ReadParticipantById(ctx context.Context, id int32) (*models.Participant, error) {
userId := ctx.Value("user_id").(int32)
panic("access control is not implemented yet")
return service.participantStorage.ReadParticipantById(ctx, id)
}
func (service *ParticipantService) UpdateParticipant(ctx context.Context, participant *models.Participant) error {
userId := ctx.Value("user_id").(int32)
panic("access control is not implemented yet")
return service.participantStorage.UpdateParticipant(ctx, participant)
}
func (service *ParticipantService) DeleteParticipant(ctx context.Context, id int32) error {
userId := ctx.Value("user_id").(int32)
panic("access control is not implemented yet")
return service.participantStorage.DeleteParticipant(ctx, id)
}