cart

package
v0.0.0-...-e4a3b16 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 4 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         uint
	CreatedAt  time.Time
	UpdatedAt  time.Time
	DeletedAt  *time.Time
	UserID     uint
	TotalPrice int
}

func NewCart

func NewCart(userId int, totalPrice int, createdAt time.Time, updatedAt time.Time) Cart

func (*Cart) ModifyCart

func (oldCart *Cart) ModifyCart(newTotal int, updated time.Time) Cart

type CartProduct

type CartProduct struct {
	ID        uint
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time
	CartID    uint
	ProductID uint
	Count     int
	Price     int
}

func NewCartProduct

func NewCartProduct(
	cartId int,
	productID int,
	count int,
	price int,
	createdAt time.Time,
	updatedAt time.Time,
) CartProduct

func (*CartProduct) ModifyCartProduct

func (oldCartProduct *CartProduct) ModifyCartProduct(newPrice int, newCount int, updated time.Time) CartProduct

type CartWithProduct

type CartWithProduct struct {
	ID        int
	CartID    int
	Product   []Product
	Count     int
	Price     int
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time
}

type CreateCartData

type CreateCartData struct {
	ProductID int `validate:"required"`
	Count     int `validate:"required"`
}

type Product

type Product struct {
	ID    int
	Name  string
	Image string
}

func ConvertProduct

func ConvertProduct(id int, name string, image string) Product

type Repository

type Repository interface {
	FindCartByUserID(int) (*Cart, error)
	CreateCart(Cart) (*Cart, error)
	UpdateCart(Cart) (*Cart, error)
	FindCartProduct(int, int) (*CartProduct, error)
	FindCartProductByCart(int) ([]CartProduct, error)
	CreateCartProduct(CartProduct) (*CartProduct, error)
	UpdateCartProduct(CartProduct) (*CartProduct, error)
	SumPrice(int) int
}

type Service

type Service interface {
	CreateCart(int, CreateCartData) error
	FindCartByUserID(userID int) ([]CartProduct, error)
}

func NewService

func NewService(repository Repository, productRepo productServ.Repository) Service

Jump to

Keyboard shortcuts

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