87 lines
3 KiB
Go
87 lines
3 KiB
Go
package usecase
|
|
|
|
import (
|
|
"context"
|
|
"git.sch9.ru/new_gate/ms-tester/internal/models"
|
|
"git.sch9.ru/new_gate/ms-tester/internal/tester"
|
|
)
|
|
|
|
type ContestUseCase struct {
|
|
contestRepo tester.ContestRepository
|
|
}
|
|
|
|
func NewContestUseCase(
|
|
contestRepo tester.ContestRepository,
|
|
) *ContestUseCase {
|
|
return &ContestUseCase{
|
|
contestRepo: contestRepo,
|
|
}
|
|
}
|
|
|
|
func (uc *ContestUseCase) CreateContest(ctx context.Context, title string) (int32, error) {
|
|
return uc.contestRepo.CreateContest(ctx, title)
|
|
}
|
|
|
|
func (uc *ContestUseCase) ReadContestById(ctx context.Context, id int32) (*models.Contest, error) {
|
|
return uc.contestRepo.ReadContestById(ctx, id)
|
|
}
|
|
|
|
func (uc *ContestUseCase) DeleteContest(ctx context.Context, id int32) error {
|
|
return uc.contestRepo.DeleteContest(ctx, id)
|
|
}
|
|
|
|
func (uc *ContestUseCase) AddTask(ctx context.Context, contestId int32, taskId int32) (id int32, err error) {
|
|
return uc.contestRepo.AddTask(ctx, contestId, taskId)
|
|
}
|
|
|
|
func (uc *ContestUseCase) DeleteTask(ctx context.Context, taskId int32) error {
|
|
return uc.contestRepo.DeleteTask(ctx, taskId)
|
|
}
|
|
|
|
func (uc *ContestUseCase) AddParticipant(ctx context.Context, contestId int32, userId int32) (id int32, err error) {
|
|
return uc.contestRepo.AddParticipant(ctx, contestId, userId)
|
|
}
|
|
|
|
func (uc *ContestUseCase) DeleteParticipant(ctx context.Context, participantId int32) error {
|
|
return uc.contestRepo.DeleteParticipant(ctx, participantId)
|
|
}
|
|
|
|
func (uc *ContestUseCase) ReadTasks(ctx context.Context, contestId int32) ([]*models.TasksListItem, error) {
|
|
return uc.contestRepo.ReadTasks(ctx, contestId)
|
|
}
|
|
|
|
func (uc *ContestUseCase) ListContests(ctx context.Context, filter models.ContestsFilter) (*models.ContestsList, error) {
|
|
return uc.contestRepo.ListContests(ctx, filter)
|
|
}
|
|
|
|
func (uc *ContestUseCase) ListParticipants(ctx context.Context, filter models.ParticipantsFilter) (*models.ParticipantsList, error) {
|
|
return uc.contestRepo.ListParticipants(ctx, filter)
|
|
}
|
|
|
|
func (uc *ContestUseCase) UpdateContest(ctx context.Context, id int32, contestUpdate models.ContestUpdate) error {
|
|
return uc.contestRepo.UpdateContest(ctx, id, contestUpdate)
|
|
}
|
|
|
|
func (uc *ContestUseCase) UpdateParticipant(ctx context.Context, id int32, participantUpdate models.ParticipantUpdate) error {
|
|
return uc.contestRepo.UpdateParticipant(ctx, id, participantUpdate)
|
|
}
|
|
|
|
func (uc *ContestUseCase) ReadSolution(ctx context.Context, id int32) (*models.Solution, error) {
|
|
return uc.contestRepo.ReadSolution(ctx, id)
|
|
}
|
|
|
|
func (uc *ContestUseCase) CreateSolution(ctx context.Context, creation *models.SolutionCreation) (int32, error) {
|
|
return uc.contestRepo.CreateSolution(ctx, creation)
|
|
}
|
|
|
|
func (uc *ContestUseCase) ListSolutions(ctx context.Context, filter models.SolutionsFilter) (*models.SolutionsList, error) {
|
|
return uc.contestRepo.ListSolutions(ctx, filter)
|
|
}
|
|
|
|
func (uc *ContestUseCase) ReadTask(ctx context.Context, id int32) (*models.Task, error) {
|
|
return uc.contestRepo.ReadTask(ctx, id)
|
|
}
|
|
|
|
func (uc *ContestUseCase) ReadMonitor(ctx context.Context, contestId int32) (*models.Monitor, error) {
|
|
return uc.contestRepo.ReadMonitor(ctx, contestId)
|
|
}
|