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
|
|
|
}
|
2024-11-11 11:41:51 +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)
|
|
|
|
}
|