Skip to content

Commit

Permalink
refactor(application): rename use case receivers
Browse files Browse the repository at this point in the history
  • Loading branch information
bastean committed Sep 5, 2024
1 parent b1d4e18 commit d0bd981
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions pkg/context/user/application/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ type Create struct {
repository.Repository
}

func (create *Create) Run(user *user.User) error {
err := create.Repository.Create(user)
func (use *Create) Run(user *user.User) error {
err := use.Repository.Create(user)

if err != nil {
return errors.BubbleUp(err, "Run")
Expand Down
4 changes: 2 additions & 2 deletions pkg/context/user/application/created/created.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ type Created struct {
transfers.Transfer
}

func (created *Created) Run(event *user.CreatedSucceeded) error {
err := created.Transfer.Submit(event.Attributes)
func (use *Created) Run(event *user.CreatedSucceeded) error {
err := use.Transfer.Submit(event.Attributes)

if err != nil {
return errors.BubbleUp(err, "Run")
Expand Down
8 changes: 4 additions & 4 deletions pkg/context/user/application/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ type Delete struct {
hashing.Hashing
}

func (delete *Delete) Run(id *user.Id, password *user.Password) error {
found, err := delete.Repository.Search(&repository.SearchCriteria{
func (use *Delete) Run(id *user.Id, password *user.Password) error {
found, err := use.Repository.Search(&repository.SearchCriteria{
Id: id,
})

if err != nil {
return errors.BubbleUp(err, "Run")
}

err = service.IsPasswordInvalid(delete.Hashing, found.Password.Value, password.Value)
err = service.IsPasswordInvalid(use.Hashing, found.Password.Value, password.Value)

if err != nil {
return errors.BubbleUp(err, "Run")
}

err = delete.Repository.Delete(found.Id)
err = use.Repository.Delete(found.Id)

if err != nil {
return errors.BubbleUp(err, "Run")
Expand Down
6 changes: 3 additions & 3 deletions pkg/context/user/application/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ type Login struct {
hashing.Hashing
}

func (login *Login) Run(email *user.Email, password *user.Password) (*user.User, error) {
found, err := login.Repository.Search(&repository.SearchCriteria{
func (use *Login) Run(email *user.Email, password *user.Password) (*user.User, error) {
found, err := use.Repository.Search(&repository.SearchCriteria{
Email: email,
})

if err != nil {
return nil, errors.BubbleUp(err, "Run")
}

err = service.IsPasswordInvalid(login.Hashing, found.Password.Value, password.Value)
err = service.IsPasswordInvalid(use.Hashing, found.Password.Value, password.Value)

if err != nil {
return nil, errors.BubbleUp(err, "Run")
Expand Down
4 changes: 2 additions & 2 deletions pkg/context/user/application/read/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ type Read struct {
repository.Repository
}

func (read *Read) Run(id *user.Id) (*user.User, error) {
found, err := read.Repository.Search(&repository.SearchCriteria{
func (use *Read) Run(id *user.Id) (*user.User, error) {
found, err := use.Repository.Search(&repository.SearchCriteria{
Id: id,
})

Expand Down
8 changes: 4 additions & 4 deletions pkg/context/user/application/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ type Update struct {
hashing.Hashing
}

func (update *Update) Run(account *user.User, updated *user.Password) error {
found, err := update.Repository.Search(&repository.SearchCriteria{
func (use *Update) Run(account *user.User, updated *user.Password) error {
found, err := use.Repository.Search(&repository.SearchCriteria{
Id: account.Id,
})

if err != nil {
return errors.BubbleUp(err, "Run")
}

err = service.IsPasswordInvalid(update.Hashing, found.Password.Value, account.Password.Value)
err = service.IsPasswordInvalid(use.Hashing, found.Password.Value, account.Password.Value)

if err != nil {
return errors.BubbleUp(err, "Run")
Expand All @@ -34,7 +34,7 @@ func (update *Update) Run(account *user.User, updated *user.Password) error {

account.Verified = found.Verified

err = update.Repository.Update(account)
err = use.Repository.Update(account)

if err != nil {
return errors.BubbleUp(err, "Run")
Expand Down
6 changes: 3 additions & 3 deletions pkg/context/user/application/verify/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ type Verify struct {
repository.Repository
}

func (verify *Verify) Run(id *user.Id) error {
found, err := verify.Repository.Search(&repository.SearchCriteria{
func (use *Verify) Run(id *user.Id) error {
found, err := use.Repository.Search(&repository.SearchCriteria{
Id: id,
})

Expand All @@ -23,7 +23,7 @@ func (verify *Verify) Run(id *user.Id) error {
return nil
}

err = verify.Repository.Verify(id)
err = use.Repository.Verify(id)

if err != nil {
return errors.BubbleUp(err, "Run")
Expand Down

0 comments on commit d0bd981

Please sign in to comment.