Last active
November 7, 2019 02:31
-
-
Save manakuro/70066010dc4d6f56f62547d9bed3205f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package interactor | |
import ( | |
"github.com/manakuro/golang-clean-architecture/domain/model" | |
"github.com/manakuro/golang-clean-architecture/usecase/presenter" | |
"github.com/manakuro/golang-clean-architecture/usecase/repository" | |
) | |
type userInteractor struct { | |
UserRepository repository.UserRepository | |
UserPresenter presenter.UserPresenter | |
} | |
type UserInteractor interface { | |
Get(u []*model.User) ([]*model.User, error) | |
} | |
func NewUserInteractor(r repository.UserRepository, p presenter.UserPresenter) UserInteractor { | |
return &userInteractor{r, p} | |
} | |
func (us *userInteractor) Get(u []*model.User) ([]*model.User, error) { | |
u, err := us.UserRepository.FindAll(u) | |
if err != nil { | |
return nil, err | |
} | |
return us.UserPresenter.ResponseUsers(u), nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment