repository

package
v0.0.0-...-2551f53 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCartRepository

func NewCartRepository(db *DB) *cartRepo

func NewPaymentRepository

func NewPaymentRepository(db *DB) *paymentRepo

func NewProductRepository

func NewProductRepository(db *DB) *productRepo

func NewRepository

func NewRepository(db *DB) *repository

func NewUserRepository

func NewUserRepository(db *DB) *userRepo

Types

type CartRepository

type CartRepository interface {
	CreateItem(ctx context.Context, data *model.CartItem) (*model.CartItem, error)
	UpdateItem(ctx context.Context, data *model.CartItem) (*model.CartItem, error)
	DeleteItem(ctx context.Context, cartID int64, prodID int64) error
	GetItem(ctx context.Context, cartID int64, prodID int64) (*model.CartItem, error)
	GetItems(ctx context.Context, cartID int64) ([]model.CartItem, error)
	Create(ctx context.Context, username string, code string) (*model.Cart, error)
	Update(ctx context.Context, data *model.Cart) (*model.Cart, error)
	Delete(ctx context.Context, id int64) error
	GetByID(ctx context.Context, id int64) (*model.Cart, error)
	GetByCode(ctx context.Context, code string) (*model.Cart, error)
	GetActiveCart(ctx context.Context) (*model.Cart, error)
}

type DB

type DB struct {
	*gorm.DB
}

func NewDB

func NewDB(connStr string) *DB

type PaymentRepository

type PaymentRepository interface {
	Create(ctx context.Context, data *model.Payment) (*model.Payment, error)
}

type ProductRepository

type ProductRepository interface {
	Create(ctx context.Context, data *model.Product) (*model.Product, error)
	Update(ctx context.Context, id int64, data *model.Product) (*model.Product, error)
	DeleteByID(ctx context.Context, id int64) error
	GetByID(ctx context.Context, id int64) (*model.Product, error)
	GetByCode(ctx context.Context, code string) (*model.Product, error)
	GetBySlug(ctx context.Context, slug string) (*model.Product, error)
	GetAll(ctx context.Context) ([]model.Product, error)
}

type Repository

type Repository interface {
	Product() ProductRepository
	Cart() CartRepository
	Payment() PaymentRepository
	User() UserRepository
}

type UserRepository

type UserRepository interface {
	GetByUsername(ctx context.Context, username string) (*model.User, error)
	Create(ctx context.Context, data *model.User) (*model.User, error)
}

Jump to

Keyboard shortcuts

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