52 lines
2.4 KiB
Go
52 lines
2.4 KiB
Go
package tester
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"git.sch9.ru/new_gate/ms-tester/internal/models"
|
|
"github.com/jmoiron/sqlx"
|
|
)
|
|
|
|
type Querier interface {
|
|
Rebind(query string) string
|
|
QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
|
|
GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
|
|
ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
|
|
SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
|
|
}
|
|
|
|
type Tx interface {
|
|
Querier
|
|
Commit() error
|
|
Rollback() error
|
|
}
|
|
|
|
type ProblemPostgresRepository interface {
|
|
BeginTx(ctx context.Context) (Tx, error)
|
|
DB() Querier
|
|
CreateProblem(ctx context.Context, q Querier, title string) (int32, error)
|
|
ReadProblemById(ctx context.Context, q Querier, id int32) (*models.Problem, error)
|
|
DeleteProblem(ctx context.Context, q Querier, id int32) error
|
|
ListProblems(ctx context.Context, q Querier, filter models.ProblemsFilter) (*models.ProblemsList, error)
|
|
UpdateProblem(ctx context.Context, q Querier, id int32, heading models.ProblemUpdate) error
|
|
}
|
|
|
|
type ContestRepository interface {
|
|
CreateContest(ctx context.Context, title string) (int32, error)
|
|
ReadContestById(ctx context.Context, id int32) (*models.Contest, error)
|
|
DeleteContest(ctx context.Context, id int32) error
|
|
AddTask(ctx context.Context, contestId int32, taskId int32) (int32, error)
|
|
DeleteTask(ctx context.Context, taskId int32) error
|
|
AddParticipant(ctx context.Context, contestId int32, userId int32) (int32, error)
|
|
DeleteParticipant(ctx context.Context, participantId int32) error
|
|
ReadTasks(ctx context.Context, contestId int32) ([]*models.TasksListItem, error)
|
|
ListContests(ctx context.Context, filter models.ContestsFilter) (*models.ContestsList, error)
|
|
ListParticipants(ctx context.Context, filter models.ParticipantsFilter) (*models.ParticipantsList, error)
|
|
UpdateContest(ctx context.Context, id int32, contestUpdate models.ContestUpdate) error
|
|
UpdateParticipant(ctx context.Context, id int32, participantUpdate models.ParticipantUpdate) error
|
|
ReadSolution(ctx context.Context, id int32) (*models.Solution, error)
|
|
CreateSolution(ctx context.Context, creation *models.SolutionCreation) (int32, error)
|
|
ListSolutions(ctx context.Context, filter models.SolutionsFilter) (*models.SolutionsList, error)
|
|
ReadTask(ctx context.Context, id int32) (*models.Task, error)
|
|
ReadMonitor(ctx context.Context, id int32) (*models.Monitor, error)
|
|
}
|