36 lines
945 B
Go
36 lines
945 B
Go
package usecase
|
|
|
|
import (
|
|
"context"
|
|
"git.sch9.ru/new_gate/ms-tester/internal/models"
|
|
"git.sch9.ru/new_gate/ms-tester/internal/problems"
|
|
"git.sch9.ru/new_gate/ms-tester/pkg/external/pandoc"
|
|
)
|
|
|
|
type ProblemUseCase struct {
|
|
problemRepo problems.ProblemPostgresRepository
|
|
pandocClient pandoc.PandocClient
|
|
}
|
|
|
|
func NewProblemUseCase(
|
|
problemRepo problems.ProblemPostgresRepository,
|
|
pandocClient pandoc.PandocClient,
|
|
) *ProblemUseCase {
|
|
return &ProblemUseCase{
|
|
problemRepo: problemRepo,
|
|
pandocClient: pandocClient,
|
|
}
|
|
}
|
|
|
|
func (u *ProblemUseCase) CreateProblem(ctx context.Context, title string) (int32, error) {
|
|
return u.problemRepo.CreateProblem(ctx, title)
|
|
}
|
|
|
|
func (u *ProblemUseCase) ReadProblemById(ctx context.Context, id int32) (*models.Problem, error) {
|
|
return u.problemRepo.ReadProblemById(ctx, id)
|
|
}
|
|
|
|
func (u *ProblemUseCase) DeleteProblem(ctx context.Context, id int32) error {
|
|
return u.problemRepo.DeleteProblem(ctx, id)
|
|
}
|