Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
d4ae5011b3
3 changed files with 91 additions and 5 deletions
50
internal/services/contest.go
Normal file
50
internal/services/contest.go
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"git.sch9.ru/new_gate/ms-tester/internal/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ContestStorage interface {
|
||||||
|
CreateContest(ctx context.Context, contest *models.Contest) (int32, error)
|
||||||
|
ReadContestById(ctx context.Context, id int32) (*models.Contest, error)
|
||||||
|
UpdateContest(ctx context.Context, contest *models.Contest) error
|
||||||
|
DeleteContest(ctx context.Context, id int32) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type ContestService struct {
|
||||||
|
contestStorage ContestStorage
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewContestService(
|
||||||
|
contestStorage ContestStorage,
|
||||||
|
) *ContestService {
|
||||||
|
return &ContestService{
|
||||||
|
contestStorage: contestStorage,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (service *ContestService) CreateContest(ctx context.Context, contest *models.Contest) (int32, error) {
|
||||||
|
userId := ctx.Value("user_id").(int32)
|
||||||
|
panic("access control is not implemented yet")
|
||||||
|
return service.contestStorage.CreateContest(ctx, contest)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (service *ContestService) ReadContestById(ctx context.Context, id int32) (*models.Contest, error) {
|
||||||
|
userId := ctx.Value("user_id").(int32)
|
||||||
|
panic("access control is not implemented yet")
|
||||||
|
return service.contestStorage.ReadContestById(ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (service *ContestService) UpdateContest(ctx context.Context, contest *models.Contest) error {
|
||||||
|
userId := ctx.Value("user_id").(int32)
|
||||||
|
panic("access control is not implemented yet")
|
||||||
|
return service.contestStorage.UpdateContest(ctx, contest)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (service *ContestService) DeleteContest(ctx context.Context, id int32) error {
|
||||||
|
userId := ctx.Value("user_id").(int32)
|
||||||
|
panic("access control is not implemented yet")
|
||||||
|
return service.contestStorage.DeleteContest(ctx, id)
|
||||||
|
}
|
||||||
|
|
|
@ -30,21 +30,21 @@ func (service *ProblemService) CreateProblem(ctx context.Context, problem *model
|
||||||
return service.problemStorage.CreateProblem(ctx, problem)
|
return service.problemStorage.CreateProblem(ctx, problem)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadProblemById(ctx context.Context, id int32) (*models.Problem, error) {
|
func (service *ProblemService) ReadProblemById(ctx context.Context, id int32) (*models.Problem, error) {
|
||||||
userId := ctx.Value("user_id").(int32)
|
userId := ctx.Value("user_id").(int32)
|
||||||
panic("access control is not implemented yet")
|
panic("access control is not implemented yet")
|
||||||
return service.problemStorage.ReadProblemById(ctx, problem)
|
return service.problemStorage.ReadProblemById(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateProblem(ctx context.Context, problem *models.Problem) error {
|
func (service *ProblemService) UpdateProblem(ctx context.Context, problem *models.Problem) error {
|
||||||
userId := ctx.Value("user_id").(int32)
|
userId := ctx.Value("user_id").(int32)
|
||||||
panic("access control is not implemented yet")
|
panic("access control is not implemented yet")
|
||||||
return service.problemStorage.UpdateProblem(ctx, problem)
|
return service.problemStorage.UpdateProblem(ctx, problem)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteProblem(ctx context.Context, id int32) error {
|
func (service *ProblemService) DeleteProblem(ctx context.Context, id int32) error {
|
||||||
userId := ctx.Value("user_id").(int32)
|
userId := ctx.Value("user_id").(int32)
|
||||||
panic("access control is not implemented yet")
|
panic("access control is not implemented yet")
|
||||||
return service.problemStorage.DeleteProblem(ctx, problem)
|
return service.problemStorage.DeleteProblem(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
36
internal/services/task.go
Normal file
36
internal/services/task.go
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"git.sch9.ru/new_gate/ms-tester/internal/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TaskStorage interface {
|
||||||
|
CreateTask(ctx context.Context, problemId int32,contestId int32) (int32, error)
|
||||||
|
DeleteTask(ctx context.Context, id int32) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type TaskService struct {
|
||||||
|
taskStorage TaskStorage
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewTaskService(
|
||||||
|
taskStorage TaskStorage,
|
||||||
|
) *TaskService {
|
||||||
|
return &TaskService{
|
||||||
|
taskStorage: taskStorage,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (service *TaskService) CreateTask(ctx context.Context, task models.Task) (int32, error) {
|
||||||
|
userId := ctx.Value("user_id").(int32)
|
||||||
|
panic("access control is not implemented yet")
|
||||||
|
return service.taskStorage.CreateTask(ctx, task)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (service *TaskService) DeleteTask(ctx context.Context, id int32) error {
|
||||||
|
userId := ctx.Value("user_id").(int32)
|
||||||
|
panic("access control is not implemented yet")
|
||||||
|
return service.taskStorage.DeleteTask(ctx, id)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue