ms-tester/internal/contests/usecase/usecase.go

48 lines
1.4 KiB
Go
Raw Normal View History

2024-10-09 18:55:16 +00:00
package usecase
2024-08-16 16:50:47 +00:00
import (
"context"
2024-10-09 18:55:16 +00:00
"git.sch9.ru/new_gate/ms-tester/internal/contests"
2024-10-13 16:21:12 +00:00
"git.sch9.ru/new_gate/ms-tester/internal/models"
2024-08-16 16:50:47 +00:00
)
2024-10-13 14:01:36 +00:00
type ContestUseCase struct {
contestRepo contests.ContestRepository
2024-08-16 16:50:47 +00:00
}
2024-10-13 14:01:36 +00:00
func NewContestUseCase(
contestRepo contests.ContestRepository,
) *ContestUseCase {
return &ContestUseCase{
contestRepo: contestRepo,
2024-08-16 16:50:47 +00:00
}
}
2024-10-13 14:01:36 +00:00
func (uc *ContestUseCase) CreateContest(ctx context.Context, title string) (int32, error) {
return uc.contestRepo.CreateContest(ctx, title)
2024-08-16 16:50:47 +00:00
}
2024-10-13 14:01:36 +00:00
func (uc *ContestUseCase) ReadContestById(ctx context.Context, id int32) (*models.Contest, error) {
return uc.contestRepo.ReadContestById(ctx, id)
2024-08-16 16:50:47 +00:00
}
2024-10-13 14:01:36 +00:00
func (uc *ContestUseCase) DeleteContest(ctx context.Context, id int32) error {
return uc.contestRepo.DeleteContest(ctx, id)
2024-08-16 16:50:47 +00:00
}
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)
}