order

package
v0.0.0-...-f8764fd Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
	UseCase UseCase
}

func (*Controller) CreateOrder

func (ctrl *Controller) CreateOrder(c *gin.Context)

type InvoiceOrder

type InvoiceOrder struct {
	Order       Order
	OrderDetail []OrderDetail
}

type Order

type Order struct {
	ID        string    `json:"id" gorm:"type:uuid;default:uuid_generate_v4();primary_key"`
	UserID    string    `json:"userId"`
	TotalCart int64     `json:"totalCart" gorm:"null"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type OrderDetail

type OrderDetail struct {
	ID        string    `gorm:"type:uuid;default:uuid_generate_v4();primary_key" json:"id"`
	OrderID   string    `gorm:"not null" json:"orderId"`
	ProductID string    `gorm:"not null" json:"productId"`
	Quantity  int64     `gorm:"not null" json:"quantity"`
	Price     int64     `gorm:"not null" json:"price"`
	PromoCode string    `gorm:"not null" json:"promoCode"`
	Total     int64     `gorm:"not null" json:"total"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type OrderRepositoryMock

type OrderRepositoryMock struct {
	Mock mock.Mock
}

func (*OrderRepositoryMock) CreateOrder

func (repository *OrderRepositoryMock) CreateOrder(order *Order) error

func (*OrderRepositoryMock) CreateOrderDetail

func (repository *OrderRepositoryMock) CreateOrderDetail(orderDetail *OrderDetail) error

func (*OrderRepositoryMock) FindAllOrderDetailByOrderID

func (repository *OrderRepositoryMock) FindAllOrderDetailByOrderID(id string) (resultOrderDetail []OrderDetail, err error)

func (*OrderRepositoryMock) FindPromoByID

func (repository *OrderRepositoryMock) FindPromoByID(id string) (resultsPromo *products.Promo, err error)

func (*OrderRepositoryMock) GetAll

func (repository *OrderRepositoryMock) GetAll() (orderResult []Order, err error)

func (*OrderRepositoryMock) GetAllCart

func (repository *OrderRepositoryMock) GetAllCart() (resultCart []cart.Cart, err error)

func (*OrderRepositoryMock) GetByOrderID

func (repository *OrderRepositoryMock) GetByOrderID(id string) (resultOrder []Order, err error)

func (*OrderRepositoryMock) GetProductByID

func (repository *OrderRepositoryMock) GetProductByID(id string) (resultProduct *products.Products, err error)

func (*OrderRepositoryMock) UpdateProduct

func (repository *OrderRepositoryMock) UpdateProduct(product *products.Products) error

func (*OrderRepositoryMock) Upsert

func (repository *OrderRepositoryMock) Upsert(order *Order) error

type Repository

type Repository interface {
	CreateOrder(order *Order) error
	CreateOrderDetail(order *OrderDetail) error
	GetByOrderID(id string) (resultOrder []Order, err error)
	GetAll() (orderResult []Order, err error)
	Upsert(order *Order) error
	FindAllOrderDetailByOrderID(id string) (resultOrderDetail []OrderDetail, err error)

	// cart domain repository
	GetAllCart() (resultCart []cart.Cart, err error)

	//product domain repository
	GetProductByID(id string) (resultProduct *products.Products, err error)
	UpdateProduct(product *products.Products) error
	FindPromoByID(id string) (resultsPromo *products.Promo, err error)
}

func NewRepository

func NewRepository(db *gorm.DB) Repository

type UseCase

type UseCase interface {
	PlaceOrder() (resultOrder *InvoiceOrder, err error)
}

func NewUseCase

func NewUseCase(repo Repository) UseCase

Jump to

Keyboard shortcuts

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