48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package usecase
|
|
|
|
import (
|
|
"context"
|
|
"git.sch9.ru/new_gate/ms-tester/internal/contests"
|
|
"git.sch9.ru/new_gate/ms-tester/internal/models"
|
|
)
|
|
|
|
type ContestUseCase struct {
|
|
contestRepo contests.ContestRepository
|
|
}
|
|
|
|
func NewContestUseCase(
|
|
contestRepo contests.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)
|
|
}
|