cart

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: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cart

type Cart struct {
	ID        string    `gorm:"type:uuid;default:uuid_generate_v4();primary_key" json:"id"`
	UserID    string    `gorm:"null" json:"userId"`
	ProductID string    `gorm:"not null" json:"productId"`
	Quantity  int64     `gorm:"not null" json:"quantity"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type CartRepositoryMock

type CartRepositoryMock struct {
	Mock mock.Mock
}

func (*CartRepositoryMock) Delete

func (repository *CartRepositoryMock) Delete(cartID int64) error

func (*CartRepositoryMock) DeleteAll

func (repository *CartRepositoryMock) DeleteAll() error

func (*CartRepositoryMock) GetAll

func (repository *CartRepositoryMock) GetAll() ([]Cart, error)

func (*CartRepositoryMock) GetByID

func (repository *CartRepositoryMock) GetByID(cartID string) (*Cart, error)

func (*CartRepositoryMock) UpdateInsert

func (repository *CartRepositoryMock) UpdateInsert(cart *Cart) error

type Controller

type Controller struct {
	UseCase UseCase
}

func (*Controller) AddItemToCart

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

func (*Controller) DeleteItemFromCart

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

func (*Controller) GetCartInfo

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

func (*Controller) ResetCart

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

type Repository

type Repository interface {
	GetAll() ([]Cart, error)
	UpdateInsert(cart *Cart) error
	Delete(cartID int64) error
	DeleteAll() error
}

func NewRepository

func NewRepository(db *gorm.DB) Repository

type UseCase

type UseCase interface {
	GetCartInfo() ([]Cart, error)
	AddItemToCart(item Cart) (string, error)
	DeleteItemFromCart(id int64) (string, error)
	ResetCart() (string, 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