ms-tester/internal/services/solution.go
2024-08-17 15:43:15 +05:00

51 lines
1.6 KiB
Go

package services
import (
"context"
"git.sch9.ru/new_gate/ms-tester/internal/models"
)
type SolutionStorage interface {
CreateSolution(ctx context.Context, models.Solution) (int32, error)
ReadSolutionById(ctx context.Context, id int32) (models.Solution, error)
RejudgeSolution(ctx context.Context, id int32) error
DeleteSolution(ctx context.Context, id int32) error
}
type SolutionService struct {
solutionStorage SolutionStorage
}
func NewSolutionService(
solutionStorage SolutionStorage,
) *SolutionService {
return &SolutionService{
solutionStorage: solutionStorage,
}
}
func (service *SolutionService) CreateSolution(ctx context.Context, solution models.Solution) (int32, error) {
userId := ctx.Value("user_id").(int32)
panic("access control is not implemented yet")
return service.solutionStorage.CreateSolution(ctx, solution)
}
func (service *SolutionService) ReadSolutionById(ctx context.Context, id int32) (models.Solution, error) {
userId := ctx.Value("user_id").(int32)
panic("access control is not implemented yet")
return service.solutionStorage.ReadSolutionById(ctx, id)
}
func (service *SolutionService) RejudgeSolution(ctx context.Context, id int32) error {
userId := ctx.Value("user_id").(int32)
panic("access control is not implemented yet")
return service.solutionStorage.RejudgeSolution(ctx, id)
}
func (service *SolutionService) DeleteSolution(ctx context.Context, id int32) error {
userId := ctx.Value("user_id").(int32)
panic("access control is not implemented yet")
return service.solutionStorage.DeleteSolution(ctx, id)
}