/
find_all_task.go
36 lines (28 loc) · 908 Bytes
/
find_all_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
package usecase
import (
"context"
"github.com/tiagompalte/golang-clean-arch-template/internal/app/entity"
"github.com/tiagompalte/golang-clean-arch-template/internal/app/repository"
"github.com/tiagompalte/golang-clean-arch-template/pkg/errors"
)
type FindAllTaskUseCase interface {
Execute(ctx context.Context, userID uint32) ([]entity.Task, error)
}
type FindAllTaskOutput struct {
Items []entity.Task
}
type FindAllTaskUseCaseImpl struct {
taskRepository repository.TaskRepository
}
func NewFindAllTaskUseCaseImpl(taskRepository repository.TaskRepository) FindAllTaskUseCase {
return FindAllTaskUseCaseImpl{
taskRepository: taskRepository,
}
}
func (u FindAllTaskUseCaseImpl) Execute(ctx context.Context, userID uint32) ([]entity.Task, error) {
list, err := u.taskRepository.FindByUserID(ctx, userID)
if err != nil {
return []entity.Task{}, errors.Wrap(err)
}
return list, nil
}