update
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
func GetMyContext(c *gin.Context) mycontext.Context {
|
||||
rawCtx, exists := c.Get("myCtx")
|
||||
if !exists {
|
||||
// handle missing context
|
||||
return mycontext.NewContext(c)
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,16 @@ type Order struct {
|
||||
PaymentProvider string `json:"payment_provider"`
|
||||
TableNumber string `json:"table_number"`
|
||||
OrderItems []OrderItem `json:"order_items"`
|
||||
PartnerID int64 `json:"partner_id"`
|
||||
}
|
||||
|
||||
type OrderCustomer struct {
|
||||
CustomerName string `json:"customer_name" validate:"required"`
|
||||
CustomerPhone string `json:"customer_phone"`
|
||||
CustomerEmail string `json:"customer_email"`
|
||||
TableNumber string `json:"table_number" validate:"required"`
|
||||
OrderItems []OrderItem `json:"order_items" validate:"required"`
|
||||
PartnerID int64 `json:"partner_id" validate:"required"`
|
||||
}
|
||||
|
||||
type CustomerOrder struct {
|
||||
@@ -82,8 +92,9 @@ func (o *OrderParam) ToOrderEntity(ctx mycontext.Context) entity.OrderSearch {
|
||||
}
|
||||
|
||||
type OrderItem struct {
|
||||
ProductID int64 `json:"product_id" validate:"required"`
|
||||
Quantity int `json:"quantity" validate:"required"`
|
||||
ProductID int64 `json:"product_id" validate:"required"`
|
||||
Quantity int `json:"quantity" validate:"required"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
func (o *Order) ToEntity(partnerID, createdBy int64) *entity.OrderRequest {
|
||||
@@ -143,3 +154,23 @@ func (o *OrderParamCustomer) ToOrderEntity(ctx mycontext.Context) entity.OrderSe
|
||||
type OrderPrintDetail struct {
|
||||
ID int64 `form:"id" json:"id" example:"10"`
|
||||
}
|
||||
|
||||
func (o *OrderCustomer) ToEntity(partnerID, createdBy int64) *entity.OrderRequest {
|
||||
orderItems := make([]entity.OrderItemRequest, len(o.OrderItems))
|
||||
for i, item := range o.OrderItems {
|
||||
orderItems[i] = entity.OrderItemRequest{
|
||||
ProductID: item.ProductID,
|
||||
Quantity: item.Quantity,
|
||||
Description: item.Description,
|
||||
}
|
||||
}
|
||||
|
||||
return &entity.OrderRequest{
|
||||
PartnerID: partnerID,
|
||||
OrderItems: orderItems,
|
||||
CreatedBy: createdBy,
|
||||
Source: "ONLINE_ORDER",
|
||||
CustomerName: o.CustomerName,
|
||||
TableNumber: o.TableNumber,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user