-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7334d6
commit 6b993da
Showing
17 changed files
with
549 additions
and
180 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,35 @@ | ||
package domain | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/google/uuid" | ||
"github.com/thangchung/go-coffeeshop/pkg/event" | ||
gen "github.com/thangchung/go-coffeeshop/proto/gen" | ||
) | ||
|
||
type ( | ||
QueryOrderFulfillmentRepo interface { | ||
GetListOrderFulfillment() ([]gen.OrderDto, error) | ||
OrderRepo interface { | ||
GetAll(context.Context) ([]gen.OrderDto, error) | ||
GetOrderByID(context.Context, uuid.UUID) (*Order, error) | ||
Create(context.Context, *gen.OrderDto) error | ||
Update(context.Context, *gen.OrderDto) (*gen.OrderDto, error) | ||
} | ||
|
||
ProductDomainService interface { | ||
GetItemsByType(*gen.PlaceOrderRequest, bool) (*gen.GetItemsByTypeResponse, error) | ||
GetItemsByType(context.Context, *gen.PlaceOrderRequest, bool) (*gen.GetItemsByTypeResponse, error) | ||
} | ||
|
||
OrderCommand interface { | ||
Create(context.Context, *gen.OrderDto) error | ||
Update(context.Context, *gen.OrderDto) (*gen.OrderDto, error) | ||
} | ||
|
||
OrderQuery interface { | ||
GetAll(ctx context.Context) ([]gen.OrderDto, error) | ||
} | ||
|
||
BaristaOrderUpdatedEventHandler interface { | ||
Handle(context.Context, *event.BaristaOrderUpdated) error | ||
} | ||
) |
This file contains 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
24 changes: 0 additions & 24 deletions
24
internal/counter/features/eventhandlers/barista_order_updated_event_handler.go
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package command | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/thangchung/go-coffeeshop/internal/counter/domain" | ||
"github.com/thangchung/go-coffeeshop/proto/gen" | ||
) | ||
|
||
type orderCommand struct { | ||
repo domain.OrderRepo | ||
} | ||
|
||
var _ domain.OrderCommand = (*orderCommand)(nil) | ||
|
||
func NewOrderCommand(ctx context.Context, r domain.OrderRepo) domain.OrderCommand { | ||
return &orderCommand{ | ||
repo: r, | ||
} | ||
} | ||
|
||
func (d *orderCommand) Create(ctx context.Context, orderModel *gen.OrderDto) error { | ||
err := d.repo.Create(ctx, orderModel) | ||
if err != nil { | ||
return fmt.Errorf("NewOrderCommand-Create-d.repo.Create(ctx, orderModel): %w", err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (d *orderCommand) Update(ctx context.Context, orderModel *gen.OrderDto) (*gen.OrderDto, error) { | ||
order, err := d.repo.Update(ctx, orderModel) | ||
if err != nil { | ||
return nil, fmt.Errorf("NewOrderCommand-Update-d.repo.Update(ctx, orderModel): %w", err) | ||
} | ||
|
||
return order, nil | ||
} |
Oops, something went wrong.