model

package
v0.0.0-...-fefde71 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OrderStatus_name = map[int32]string{
		0: "ORDER_STATUS_UNSPECIFIED",
		1: "ORDER_STATUS_PENDING",
		2: "ORDER_STATUS_CONFIRMED",
		3: "ORDER_STATUS_PREPARING",
		4: "ORDER_STATUS_OUT_FOR_DELIVERY",
		5: "ORDER_STATUS_DELIVERED",
		6: "ORDER_STATUS_CANCELLED",
	}
	OrderStatus_value = map[string]int32{
		"ORDER_STATUS_UNSPECIFIED":      0,
		"ORDER_STATUS_PENDING":          1,
		"ORDER_STATUS_CONFIRMED":        2,
		"ORDER_STATUS_PREPARING":        3,
		"ORDER_STATUS_OUT_FOR_DELIVERY": 4,
		"ORDER_STATUS_DELIVERED":        5,
		"ORDER_STATUS_CANCELLED":        6,
	}
)

Enum value maps for OrderStatus.

View Source
var File_domain_order_model_order_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Address

type Address struct {

	// Street is the street address of the user.
	// @gotags: bson:"street"
	Street string `protobuf:"bytes,1,opt,name=street,proto3" json:"street,omitempty" bson:"street"`
	// City is the city where the user is located.
	// @gotags: bson:"city"
	City string `protobuf:"bytes,2,opt,name=city,proto3" json:"city,omitempty" bson:"city"`
	// State is the state where the user is located.
	// @gotags: bson:"state"
	State string `protobuf:"bytes,3,opt,name=state,proto3" json:"state,omitempty" bson:"state"`
	// ZipCode is the postal code of the user's location.
	// @gotags: bson:"zip_code"
	ZipCode string `protobuf:"bytes,4,opt,name=zip_code,json=zipCode,proto3" json:"zip_code,omitempty" bson:"zip_code"`
	// contains filtered or unexported fields
}

Address is a value object that represents the address of a user.

func (*Address) Descriptor deprecated

func (*Address) Descriptor() ([]byte, []int)

Deprecated: Use Address.ProtoReflect.Descriptor instead.

func (*Address) GetCity

func (x *Address) GetCity() string

func (*Address) GetState

func (x *Address) GetState() string

func (*Address) GetStreet

func (x *Address) GetStreet() string

func (*Address) GetZipCode

func (x *Address) GetZipCode() string

func (*Address) ProtoMessage

func (*Address) ProtoMessage()

func (*Address) ProtoReflect

func (x *Address) ProtoReflect() protoreflect.Message

func (*Address) Reset

func (x *Address) Reset()

func (*Address) String

func (x *Address) String() string

type CancelledState

type CancelledState struct{}

CancelledState is the cancelled state of the order.

func (*CancelledState) Next

func (s *CancelledState) Next(ctx contextx.Contextx, order *Order) (event *OrderEvent, err error)

func (*CancelledState) String

func (s *CancelledState) String() string

type ConfirmedState

type ConfirmedState struct{}

ConfirmedState is the confirmed state of the order.

func (*ConfirmedState) Next

func (s *ConfirmedState) Next(ctx contextx.Contextx, order *Order) (event *OrderEvent, err error)

func (*ConfirmedState) String

func (s *ConfirmedState) String() string

type DeliveredState

type DeliveredState struct{}

DeliveredState is the delivered state of the order.

func (*DeliveredState) Next

func (s *DeliveredState) Next(ctx contextx.Contextx, order *Order) (event *OrderEvent, err error)

func (*DeliveredState) String

func (s *DeliveredState) String() string

type Order

type Order struct {

	// ID is the unique identifier of the order.
	// @gotags: gorm:"column:id;primaryKey;not null"`
	Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" gorm:"column:id;primaryKey;not null"`
	// UserID is the unique identifier of the user.
	// @gotags: gorm:"column:user_id;not null"
	UserId string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty" gorm:"column:user_id;not null"`
	// RestaurantID is the unique identifier of the restaurant.
	// @gotags: gorm:"column:restaurant_id;not null"
	RestaurantId string `` /* 134-byte string literal not displayed */
	// PaymentID is the unique identifier of the payment.
	// @gotags: gorm:"column:payment_id"
	PaymentId string `protobuf:"bytes,10,opt,name=payment_id,json=paymentId,proto3" json:"payment_id,omitempty" gorm:"column:payment_id"`
	// DeliveryID is the unique identifier of the delivery.
	// @gotags: gorm:"column:delivery_id"
	DeliveryId string `protobuf:"bytes,4,opt,name=delivery_id,json=deliveryId,proto3" json:"delivery_id,omitempty" gorm:"column:delivery_id"`
	// Items is the items in the order.
	// @gotags: gorm:"foreignKey:order_id;references:id;constraint:OnDelete:CASCADE"`
	Items []*OrderItem `` /* 132-byte string literal not displayed */
	// TotalPrice is the total price of the order.
	// @gotags: gorm:"column:total_amount"`
	TotalAmount float64 `protobuf:"fixed64,9,opt,name=total_amount,json=totalAmount,proto3" json:"total_amount,omitempty" gorm:"column:total_amount"`
	// Status is the status of the order.
	// @gotags: gorm:"column:status;not null;default:1"`
	Status OrderStatus `` /* 129-byte string literal not displayed */
	// CreatedAt is the time the order was created.
	// @gotags: gorm:"serializer:timestamppb;type:time;column:created_at"`
	CreatedAt *timestamppb.Timestamp `` /* 146-byte string literal not displayed */
	// UpdatedAt is the time the order was last updated.
	// @gotags: gorm:"serializer:timestamppb;type:time;column:updated_at"`
	UpdatedAt *timestamppb.Timestamp `` /* 146-byte string literal not displayed */
	// contains filtered or unexported fields
}

Order is an entity and aggregate root that represents an order.

func NewOrder

func NewOrder(userID, restaurantID string, items []*OrderItem) *Order

NewOrder creates a new order.

func (*Order) Descriptor deprecated

func (*Order) Descriptor() ([]byte, []int)

Deprecated: Use Order.ProtoReflect.Descriptor instead.

func (*Order) GetCreatedAt

func (x *Order) GetCreatedAt() *timestamppb.Timestamp

func (*Order) GetDeliveryId

func (x *Order) GetDeliveryId() string

func (*Order) GetId

func (x *Order) GetId() int64

func (*Order) GetItems

func (x *Order) GetItems() []*OrderItem

func (*Order) GetPaymentId

func (x *Order) GetPaymentId() string

func (*Order) GetRestaurantId

func (x *Order) GetRestaurantId() string

func (*Order) GetStatus

func (x *Order) GetStatus() OrderStatus

func (*Order) GetTotalAmount

func (x *Order) GetTotalAmount() float64

func (*Order) GetUpdatedAt

func (x *Order) GetUpdatedAt() *timestamppb.Timestamp

func (*Order) GetUserId

func (x *Order) GetUserId() string

func (*Order) Next

func (x *Order) Next(ctx contextx.Contextx) (event *OrderEvent, err error)

Next transitions the order to the next state.

func (*Order) ProtoMessage

func (*Order) ProtoMessage()

func (*Order) ProtoReflect

func (x *Order) ProtoReflect() protoreflect.Message

func (*Order) Reset

func (x *Order) Reset()

func (*Order) String

func (x *Order) String() string

type OrderEvent

type OrderEvent struct {

	// Name is the name of the order.
	// @gotags: bson:"name"
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty" bson:"name"`
	// Handler is the handler of the order.
	// @gotags: bson:"handler_id"
	HandlerId string `protobuf:"bytes,2,opt,name=handler_id,json=handlerId,proto3" json:"handler_id,omitempty" bson:"handler_id"`
	// contains filtered or unexported fields
}

OrderEvent is an event that represents an order.

func (*OrderEvent) Descriptor deprecated

func (*OrderEvent) Descriptor() ([]byte, []int)

Deprecated: Use OrderEvent.ProtoReflect.Descriptor instead.

func (*OrderEvent) GetHandlerId

func (x *OrderEvent) GetHandlerId() string

func (*OrderEvent) GetName

func (x *OrderEvent) GetName() string

func (*OrderEvent) ProtoMessage

func (*OrderEvent) ProtoMessage()

func (*OrderEvent) ProtoReflect

func (x *OrderEvent) ProtoReflect() protoreflect.Message

func (*OrderEvent) Reset

func (x *OrderEvent) Reset()

func (*OrderEvent) String

func (x *OrderEvent) String() string

type OrderItem

type OrderItem struct {

	// OrderID is the unique identifier of the order.
	// @gotags: gorm:"column:order_id;primaryKey;not null"
	OrderId int64 `` /* 126-byte string literal not displayed */
	// MenuItemID is the unique identifier of the menu item.
	// @gotags: gorm:"column:menu_item_id;primaryKey;not null"
	MenuItemId string `` /* 140-byte string literal not displayed */
	// Quantity is the quantity of the item.
	// @gotags: gorm:"column:quantity"
	Quantity int64 `protobuf:"varint,3,opt,name=quantity,proto3" json:"quantity,omitempty" gorm:"column:quantity"`
	// Price is the price of the item.
	// @gotags: gorm:"column:price"`
	Price float64 `protobuf:"fixed64,4,opt,name=price,proto3" json:"price,omitempty" gorm:"column:price"`
	// contains filtered or unexported fields
}

OrderItem is a value object that represents an item in an order.

func NewOrderItem

func NewOrderItem(menuItemID string, price float64, quantity int) *OrderItem

NewOrderItem creates a new order item.

func (*OrderItem) Descriptor deprecated

func (*OrderItem) Descriptor() ([]byte, []int)

Deprecated: Use OrderItem.ProtoReflect.Descriptor instead.

func (*OrderItem) GetMenuItemId

func (x *OrderItem) GetMenuItemId() string

func (*OrderItem) GetOrderId

func (x *OrderItem) GetOrderId() int64

func (*OrderItem) GetPrice

func (x *OrderItem) GetPrice() float64

func (*OrderItem) GetQuantity

func (x *OrderItem) GetQuantity() int64

func (*OrderItem) ProtoMessage

func (*OrderItem) ProtoMessage()

func (*OrderItem) ProtoReflect

func (x *OrderItem) ProtoReflect() protoreflect.Message

func (*OrderItem) Reset

func (x *OrderItem) Reset()

func (*OrderItem) String

func (x *OrderItem) String() string

type OrderState

type OrderState interface {
	fmt.Stringer

	// Next is the next state of the order.
	Next(ctx contextx.Contextx, order *Order) (event *OrderEvent, err error)
}

OrderState is the interface for order state.

func UnmarshalOrderState

func UnmarshalOrderState(raw string) (OrderState, error)

type OrderStatus

type OrderStatus int32

OrderStatus is an enum that represents the status of an order.

const (
	OrderStatus_ORDER_STATUS_UNSPECIFIED      OrderStatus = 0
	OrderStatus_ORDER_STATUS_PENDING          OrderStatus = 1
	OrderStatus_ORDER_STATUS_CONFIRMED        OrderStatus = 2
	OrderStatus_ORDER_STATUS_PREPARING        OrderStatus = 3
	OrderStatus_ORDER_STATUS_OUT_FOR_DELIVERY OrderStatus = 4
	OrderStatus_ORDER_STATUS_DELIVERED        OrderStatus = 5
	OrderStatus_ORDER_STATUS_CANCELLED        OrderStatus = 6
)

func (OrderStatus) Descriptor

func (OrderStatus) Enum

func (x OrderStatus) Enum() *OrderStatus

func (OrderStatus) EnumDescriptor deprecated

func (OrderStatus) EnumDescriptor() ([]byte, []int)

Deprecated: Use OrderStatus.Descriptor instead.

func (OrderStatus) Number

func (x OrderStatus) Number() protoreflect.EnumNumber

func (OrderStatus) String

func (x OrderStatus) String() string

func (OrderStatus) Type

type OutForDeliveryState

type OutForDeliveryState struct{}

OutForDeliveryState is the out-for-delivery state of the order.

func (*OutForDeliveryState) Next

func (s *OutForDeliveryState) Next(ctx contextx.Contextx, order *Order) (event *OrderEvent, err error)

func (*OutForDeliveryState) String

func (s *OutForDeliveryState) String() string

type PendingState

type PendingState struct{}

PendingState is the pending state of the order.

func (*PendingState) Next

func (s *PendingState) Next(ctx contextx.Contextx, order *Order) (event *OrderEvent, err error)

func (*PendingState) String

func (s *PendingState) String() string

type PreparedState

type PreparedState struct{}

PreparedState is the prepared state of the order.

func (*PreparedState) Next

func (s *PreparedState) Next(ctx contextx.Contextx, order *Order) (event *OrderEvent, err error)

func (*PreparedState) String

func (s *PreparedState) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL