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

36 lines
945 B
Go
Raw Permalink Normal View History

2024-10-09 18:55:16 +00:00
package usecase
2024-08-16 15:54:23 +00:00
import (
"context"
2024-10-13 14:01:36 +00:00
"git.sch9.ru/new_gate/ms-tester/internal/models"
"git.sch9.ru/new_gate/ms-tester/internal/problems"
2024-10-09 18:55:16 +00:00
"git.sch9.ru/new_gate/ms-tester/pkg/external/pandoc"
2024-08-16 15:54:23 +00:00
)
2024-10-09 18:55:16 +00:00
type ProblemUseCase struct {
2024-10-13 14:01:36 +00:00
problemRepo problems.ProblemPostgresRepository
pandocClient pandoc.PandocClient
2024-08-16 15:54:23 +00:00
}
2024-10-09 18:55:16 +00:00
func NewProblemUseCase(
2024-10-13 14:01:36 +00:00
problemRepo problems.ProblemPostgresRepository,
2024-10-09 18:55:16 +00:00
pandocClient pandoc.PandocClient,
) *ProblemUseCase {
return &ProblemUseCase{
2024-10-13 14:01:36 +00:00
problemRepo: problemRepo,
pandocClient: pandocClient,
2024-08-16 15:54:23 +00:00
}
}
2024-10-13 14:01:36 +00:00
func (u *ProblemUseCase) CreateProblem(ctx context.Context, title string) (int32, error) {
return u.problemRepo.CreateProblem(ctx, title)
2024-08-22 22:56:03 +00:00
}
2024-10-13 14:01:36 +00:00
func (u *ProblemUseCase) ReadProblemById(ctx context.Context, id int32) (*models.Problem, error) {
return u.problemRepo.ReadProblemById(ctx, id)
2024-08-22 22:56:03 +00:00
}
2024-10-13 14:01:36 +00:00
func (u *ProblemUseCase) DeleteProblem(ctx context.Context, id int32) error {
return u.problemRepo.DeleteProblem(ctx, id)
2024-08-16 15:54:23 +00:00
}