add task service
This commit is contained in:
parent
dc032b4dd3
commit
900c9716b2
1 changed files with 36 additions and 0 deletions
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 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