order

package
v0.0.0-...-514f96b Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CancelOrderRequest

type CancelOrderRequest struct {
	OrderID   int64 `json:"order_id"   binding:"required,gte=1"`
	AccountID int64 `json:"account_id" binding:"required,gte=1"`
	ServiceID int64 `json:"service_id" binding:"required,gte=1"`
	Amount    int64 `json:"amount"     binding:"required,gt=0"`
}

func (CancelOrderRequest) ToDTO

type CancelOrderResponse

type CancelOrderResponse struct {
	Balance int64 `json:"balance"`
}

type CreateOrderRequest

type CreateOrderRequest struct {
	OrderID   int64 `json:"order_id"   binding:"required,gte=1"`
	AccountID int64 `json:"account_id" binding:"required,gte=1"`
	ServiceID int64 `json:"service_id" binding:"required,gte=1"`
	Amount    int64 `json:"amount"     binding:"required,gt=0"`
}

func (CreateOrderRequest) ToDTO

type CreateOrderResponse

type CreateOrderResponse struct {
	Order   Response `json:"order"`
	Balance int64    `json:"balance"`
}

func NewCreateOrderResponse

func NewCreateOrderResponse(entity order.Order, balance int64) CreateOrderResponse

type Handler

type Handler struct {
	*handler.BaseHandler
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(service Service, logger *zap.Logger) *Handler

func (*Handler) CancelOrder

func (h *Handler) CancelOrder(c *gin.Context)

func (*Handler) CreateOrder

func (h *Handler) CreateOrder(c *gin.Context)

func (*Handler) InitAPI

func (h *Handler) InitAPI(router *gin.RouterGroup)

func (*Handler) PayForOrder

func (h *Handler) PayForOrder(c *gin.Context)

type PayForOrderRequest

type PayForOrderRequest struct {
	OrderID   int64 `json:"order_id"   binding:"required,gte=1"`
	AccountID int64 `json:"account_id" binding:"required,gte=1"`
	ServiceID int64 `json:"service_id" binding:"required,gte=1"`
	Amount    int64 `json:"amount"     binding:"required,gt=0"`
}

func (PayForOrderRequest) ToDTO

type Response

type Response struct {
	OrderID     int64     `json:"order_id"`
	AccountID   int64     `json:"account_id"`
	ServiceID   int64     `json:"service_id"`
	Amount      int64     `json:"amount"`
	IsPaid      bool      `json:"is_paid"`
	IsCancelled bool      `json:"is_cancelled"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

func NewResponse

func NewResponse(entity order.Order) Response

type Service

type Service interface {
	CreateOrder(ctx context.Context, dto order.CreateDTO) (order.Order, int64, error)
	PayForOrder(ctx context.Context, dto order.PayForDTO) error
	CancelOrder(ctx context.Context, dto order.CancelDTO) (int64, error)
}

Jump to

Keyboard shortcuts

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