-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask.go
43 lines (34 loc) · 877 Bytes
/
task.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
Service Layer
- Contains access to DAO
- Businesss logic is written here
*/
package service
import (
"github.com/arvryna/sled/internal/model"
"github.com/arvryna/sled/internal/repository"
)
type TaskService interface {
CreateTask(task *model.Task)
ListTask() []model.Task
GetTask(taskId int) model.Task
UpdateTask(task *model.Task)
}
type taskService struct {
dao repository.DAO
}
func NewTaskService(dao repository.DAO) TaskService {
return &taskService{dao: dao}
}
func (t *taskService) CreateTask(task *model.Task) {
t.dao.NewTaskQuery().CreateTask(task)
}
func (t *taskService) ListTask() []model.Task {
return t.dao.NewTaskQuery().ListTasks()
}
func (t *taskService) GetTask(taskId int) model.Task {
return t.dao.NewTaskQuery().GetTask(taskId)
}
func (t *taskService) UpdateTask(task *model.Task) {
t.dao.NewTaskQuery().UpdateTask(task)
}