-
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
e8ea4e6
commit c8d0229
Showing
16 changed files
with
799 additions
and
143 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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package entity | ||
|
||
import ( | ||
"github.com/google/uuid" | ||
gen "github.com/thangchung/go-coffeeshop/proto/gen" | ||
) | ||
|
||
type LineItem struct { | ||
ID uuid.UUID | ||
ItemType gen.ItemType | ||
Name string | ||
Price float32 | ||
ItemStatus gen.Status | ||
IsBaristaOrder bool | ||
} | ||
|
||
func NewLineItem(itemType gen.ItemType, name string, price float32, itemStatus gen.Status, isBarista bool) *LineItem { | ||
return &LineItem{ | ||
ID: uuid.New(), | ||
ItemType: itemType, | ||
Name: name, | ||
Price: price, | ||
ItemStatus: itemStatus, | ||
IsBaristaOrder: isBarista, | ||
} | ||
} |
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,44 @@ | ||
package entity | ||
|
||
import ( | ||
"github.com/google/uuid" | ||
gen "github.com/thangchung/go-coffeeshop/proto/gen" | ||
) | ||
|
||
type Order struct { | ||
ID uuid.UUID | ||
OrderSource gen.OrderSource | ||
LoyaltyMemberID uuid.UUID | ||
OrderStatus gen.Status | ||
Location gen.Location | ||
LineItems []LineItem | ||
} | ||
|
||
func NewOrder(orderSource gen.OrderSource, loyaltyMemberID uuid.UUID, orderStatus gen.Status, location gen.Location) *Order { | ||
return &Order{ | ||
ID: uuid.New(), | ||
OrderSource: orderSource, | ||
LoyaltyMemberID: loyaltyMemberID, | ||
OrderStatus: orderStatus, | ||
Location: location, | ||
} | ||
} | ||
|
||
func (o *Order) From(request *gen.PlaceOrderRequest) (*Order, error) { | ||
loyaltyMemberID, err := uuid.Parse(request.LoyaltyMemberId) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
order := NewOrder(request.OrderSource, loyaltyMemberID, gen.Status_IN_PROGRESS, request.Location) | ||
|
||
if len(request.BaristaItems) > 0 { | ||
|
||
} | ||
|
||
if len(request.KitchenItems) > 0 { | ||
|
||
} | ||
|
||
return order, nil | ||
} |
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,40 @@ | ||
package event | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/google/uuid" | ||
gen "github.com/thangchung/go-coffeeshop/proto/gen" | ||
) | ||
|
||
type BaristaOrdered struct { | ||
OrderID uuid.UUID `json:"orderId"` | ||
ItemLineID uuid.UUID `json:"itemLineId"` | ||
ItemType gen.ItemType `json:"itemType"` | ||
} | ||
|
||
type KitchenOrdered struct { | ||
OrderID uuid.UUID `json:"orderId"` | ||
ItemLineID uuid.UUID `json:"itemLineId"` | ||
ItemType gen.ItemType `json:"itemType"` | ||
} | ||
|
||
type BaristaOrderUpdated struct { | ||
OrderID uuid.UUID `json:"orderId"` | ||
ItemLineID uuid.UUID `json:"itemLineId"` | ||
Name string `json:"name"` | ||
ItemType gen.ItemType `json:"itemType"` | ||
TimeIn time.Time `json:"timeIn"` | ||
MadeBy string `json:"madeBy"` | ||
TimeUp time.Time `json:"timeUp"` | ||
} | ||
|
||
type KitchenOrderUpdated struct { | ||
OrderID uuid.UUID `json:"orderId"` | ||
ItemLineID uuid.UUID `json:"itemLineId"` | ||
Name string `json:"name"` | ||
ItemType gen.ItemType `json:"itemType"` | ||
TimeIn time.Time `json:"timeIn"` | ||
MadeBy string `json:"madeBy"` | ||
TimeUp time.Time `json:"timeUp"` | ||
} |
Oops, something went wrong.