ms-tester/internal/services/task.go

37 lines
908 B
Go
Raw Normal View History

2024-08-16 17:02:13 +00:00
package services
import (
"context"
"git.sch9.ru/new_gate/ms-tester/internal/models"
2024-08-16 17:02:13 +00:00
)
type TaskStorage interface {
CreateTask(ctx context.Context, models.Task) (int32, error)
DeleteTask(ctx context.Context, id int32) error
2024-08-16 17:02:13 +00:00
}
type TaskService struct {
taskStorage TaskStorage
2024-08-16 17:02:13 +00:00
}
func NewTaskService(
taskStorage TaskStorage,
2024-08-16 17:02:13 +00:00
) *TaskService {
return &TaskService{
taskStorage: taskStorage,
}
2024-08-16 17:02:13 +00:00
}
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)
}
2024-08-16 17:04:49 +00:00
func (service *TaskService) DeleteTask(ctx context.Context, id int32) error {
2024-08-16 17:02:13 +00:00
userId := ctx.Value("user_id").(int32)
panic("access control is not implemented yet")
return service.taskStorage.DeleteTask(ctx, id)
}