order

package
v0.0.0-...-712712c Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateOrderRequest

type CreateOrderRequest struct {
	ClientID     int64            `json:"-"`
	RestaurantID int              `json:"rest_id"`
	Products     []ProductRequest `json:"products"`
	TotalPrice   float64          `json:"-"`
	Subtotal     float64          `json:"-"`
}

type Order

type Order struct {
	ID           int64   `db:"id"`
	ClientID     int64   `db:"client_id"`
	RestaurantID int64   `db:"rest_id"`
	TotalPrice   float64 `db:"total_price"`
	Subtotal     float64 `db:"sub_total_price"`
	LastStatus   string  `db:"last_status"`
}

type OrderDataProvider

type OrderDataProvider interface {
	GetRestaurantByID(restID int, productsIDS []int) (Restaurant, error)
}

type OrderHandler

type OrderHandler struct {
	// contains filtered or unexported fields
}

func NewOrderHandler

func NewOrderHandler(orderService *OrderService) *OrderHandler

func (*OrderHandler) CreateOrder

func (h *OrderHandler) CreateOrder(orderDataProvider OrderDataProvider) gin.HandlerFunc

func (*OrderHandler) GetOrder

func (h *OrderHandler) GetOrder(ctx *gin.Context)

func (*OrderHandler) UpdateOrderStatus

func (h *OrderHandler) UpdateOrderStatus(ctx *gin.Context)

type OrderRepo

type OrderRepo interface {
	GetOrderById(id int64) (Order, error)
	UpdateOrderStatus(id int64, status string) error
	GetOrderDetailsByOrderId(id int64) ([]OrdersDetails, error)
	Create(order CreateOrderRequest) (int64, error)
}

func NewOrderRepo

func NewOrderRepo(db *sqlx.DB) OrderRepo

type OrderRequest

type OrderRequest struct {
	ID        int64  `form:"id" json:"id"`
	NewStatus string `json:"new_status"`
}

type OrderResponse

type OrderResponse struct {
	Order `json:"order"`
	Items []orderItem `json:"items"`
}

type OrderService

type OrderService struct {
	// contains filtered or unexported fields
}

func NewOrderService

func NewOrderService(orderRepo OrderRepo) *OrderService

func (*OrderService) CreateOrder

func (os *OrderService) CreateOrder(order CreateOrderRequest, restaurant Restaurant) (int64, error)

func (*OrderService) GetOrderById

func (s *OrderService) GetOrderById(id int64) (Order, []OrdersDetails, error)

func (*OrderService) UpdateOrderStatus

func (s *OrderService) UpdateOrderStatus(id int64, status string) error

type OrdersDetails

type OrdersDetails struct {
	ID        int64   `db:"id"`
	OrderID   int64   `db:"order_id"`
	ProductID int64   `db:"product_id"`
	Quantity  int64   `db:"quantity"`
	Price     float64 `db:"price"`
}

type ProductData

type ProductData struct {
	ID    int64
	Price float64
}

type ProductRequest

type ProductRequest struct {
	ID       int `json:"id"`
	Quantity int `json:"qty"`
}

type Restaurant

type Restaurant struct {
	ID       int64
	Name     string
	Status   bool
	Lon      float64
	Lat      float64
	Address  string
	Products []ProductData
}

type RestaurantData

type RestaurantData struct {
	ID   int64  `db:"id"`
	Name string `db:"name"`
}

Jump to

Keyboard shortcuts

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