ms-tester/internal/services/solution.go

50 lines
1.6 KiB
Go
Raw Normal View History

2024-08-17 10:43:15 +00:00
package services
import (
2024-08-20 22:54:46 +00:00
"context"
"git.sch9.ru/new_gate/ms-tester/internal/models"
2024-08-17 10:43:15 +00:00
)
type SolutionStorage interface {
2024-08-20 22:54:46 +00:00
CreateSolution(ctx context.Context, solution 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
2024-08-17 10:43:15 +00:00
}
type SolutionService struct {
2024-08-20 22:54:46 +00:00
solutionStorage SolutionStorage
2024-08-17 10:43:15 +00:00
}
func NewSolutionService(
2024-08-20 22:54:46 +00:00
solutionStorage SolutionStorage,
2024-08-17 10:43:15 +00:00
) *SolutionService {
2024-08-20 22:54:46 +00:00
return &SolutionService{
solutionStorage: solutionStorage,
}
2024-08-17 10:43:15 +00:00
}
func (service *SolutionService) CreateSolution(ctx context.Context, solution models.Solution) (int32, error) {
2024-08-20 22:54:46 +00:00
//userId := ctx.Value("user_id").(int32)
panic("access control is not implemented yet")
return service.solutionStorage.CreateSolution(ctx, solution)
2024-08-17 10:43:15 +00:00
}
func (service *SolutionService) ReadSolutionById(ctx context.Context, id int32) (models.Solution, error) {
2024-08-20 22:54:46 +00:00
//userId := ctx.Value("user_id").(int32)
panic("access control is not implemented yet")
return service.solutionStorage.ReadSolutionById(ctx, id)
2024-08-17 10:43:15 +00:00
}
func (service *SolutionService) RejudgeSolution(ctx context.Context, id int32) error {
2024-08-20 22:54:46 +00:00
//userId := ctx.Value("user_id").(int32)
panic("access control is not implemented yet")
return service.solutionStorage.RejudgeSolution(ctx, id)
2024-08-17 10:43:15 +00:00
}
func (service *SolutionService) DeleteSolution(ctx context.Context, id int32) error {
2024-08-20 22:54:46 +00:00
//userId := ctx.Value("user_id").(int32)
panic("access control is not implemented yet")
return service.solutionStorage.DeleteSolution(ctx, id)
2024-08-17 10:43:15 +00:00
}