-
Notifications
You must be signed in to change notification settings - Fork 0
/
find_all_category.go
32 lines (25 loc) · 916 Bytes
/
find_all_category.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
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 FindAllCategoryUseCase interface {
Execute(ctx context.Context, userID uint32) ([]entity.Category, error)
}
type FindAllCategoryUseCaseImpl struct {
categoryRepository repository.CategoryRepository
}
func NewFindAllCategoryUseCaseImpl(categoryRepository repository.CategoryRepository) FindAllCategoryUseCase {
return FindAllCategoryUseCaseImpl{
categoryRepository: categoryRepository,
}
}
func (u FindAllCategoryUseCaseImpl) Execute(ctx context.Context, userID uint32) ([]entity.Category, error) {
list, err := u.categoryRepository.FindByUserID(ctx, userID)
if err != nil {
return []entity.Category{}, errors.Wrap(err)
}
return list, nil
}