37 lines
898 B
Go
37 lines
898 B
Go
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)
|
|
}
|
|
|