ms-tester/internal/services/tester.go
Vyacheslav1557 3c0f01630f refactor:
2024-08-16 16:05:29 +05:00

31 lines
803 B
Go

package services
import (
"context"
"git.sch9.ru/new_gate/ms-tester/internal/models"
)
type ProblemStorage interface {
CreateProblem(ctx context.Context, problem *models.Problem) (int32, error)
ReadProblem(ctx context.Context, id int32) (*models.Problem, error)
UpdateProblem(ctx context.Context, problem *models.Problem) error
DeleteProblem(ctx context.Context, id int32) error
}
type ProblemService struct {
problemStorage ProblemStorage
}
func NewProblemService(
problemStorage ProblemStorage,
) *ProblemService {
return &ProblemService{
problemStorage: problemStorage,
}
}
func (service *ProblemService) CreateProblem(ctx context.Context, problem *models.Problem) (int32, error) {
userId := ctx.Value("user_id").(int32)
return service.problemStorage.CreateProblem(ctx, problem)
}