From 900c9716b2578261a183b36eaa9ecdfff2bbfde5 Mon Sep 17 00:00:00 2001 From: dragonmuffin Date: Fri, 16 Aug 2024 22:02:13 +0500 Subject: [PATCH] add task service --- internal/services/task.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 internal/services/task.go diff --git a/internal/services/task.go b/internal/services/task.go new file mode 100644 index 0000000..dcfab65 --- /dev/null +++ b/internal/services/task.go @@ -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) +} +