add task service

This commit is contained in:
dragonmuffin 2024-08-16 22:02:13 +05:00
parent dc032b4dd3
commit 900c9716b2

36
internal/services/task.go Normal file
View 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 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)
}