db_repository

package
v0.0.0-...-5037bb9 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UsersTable        = "users"
	OrdersTable       = "orders"
	OPTable           = "order_products"
	SuppliersTable    = "suppliers"
	ProductsTable     = "products"
	CartTable         = "cart"
	CartProductsTable = "cart_products"
	CacheTokenTable   = "uid_token"
)

Variables

This section is empty.

Functions

func InitDB

func InitDB(cfg *conf.Config) *sql.DB

func NewDB

func NewDB(logger *log.Logger, cfg Config) (*sql.DB, error)

Types

type CartRepository

type CartRepository struct {
	// contains filtered or unexported fields
}

func NewCartRepository

func NewCartRepository(db *sql.DB) *CartRepository

func (CartRepository) Create

func (c CartRepository) Create(cart *models.Cart) (*models.Cart, error)

func (CartRepository) CreateProduct

func (c CartRepository) CreateProduct(cart *models.Cart) (*models.Cart, error)

func (CartRepository) DeleteAllProductFromCart

func (c CartRepository) DeleteAllProductFromCart(userID int32) error

func (CartRepository) DeleteProductFromCart

func (c CartRepository) DeleteProductFromCart(userID int32, productID int) error

func (CartRepository) GetAllProductsFromCart

func (c CartRepository) GetAllProductsFromCart(userID int32) (*[]models.Cart, error)

func (CartRepository) GetCart

func (c CartRepository) GetCart(userID int32) (int, error)

func (CartRepository) GetCartByUserID

func (c CartRepository) GetCartByUserID(userID int32) (*models.Cart, error)

func (CartRepository) GetCartProductsByID

func (c CartRepository) GetCartProductsByID(cartID int) (cartProducts []models.CartProducts, err error)

func (CartRepository) Update

func (c CartRepository) Update(cart *models.Cart) (*models.Cart, error)

type CartRepositoryI

type CartRepositoryI interface {
	Create(cart *models.Cart) (*models.Cart, error)
	CreateProduct(cart *models.Cart) (*models.Cart, error)
	GetCartByUserID(userID int32) (*models.Cart, error)
	GetCart(userID int32) (int, error)
	GetAllProductsFromCart(userID int32) (*[]models.Cart, error)
	GetCartProductsByID(id int) (cartProducts []models.CartProducts, err error)
	Update(cart *models.Cart) (*models.Cart, error)
	DeleteProductFromCart(userID int32, productID int) error
	DeleteAllProductFromCart(userID int32) error
}

type Config

type Config struct {
	Host     string
	Port     string
	Username string
	Password string
	DBName   string
}

type OrderRepository

type OrderRepository struct {
	// contains filtered or unexported fields
}

func NewOrderRepository

func NewOrderRepository(db *sql.DB) *OrderRepository

func (OrderRepository) Create

func (o OrderRepository) Create(order *models.Order) (*models.Order, error)

func (OrderRepository) GetAll

func (o OrderRepository) GetAll(userID int32) (*[]models.Order, error)

func (OrderRepository) GetOrderProductsByID

func (o OrderRepository) GetOrderProductsByID(id int32) (orderProducts []models.OrderProducts, err error)

type OrderRepositoryI

type OrderRepositoryI interface {
	Create(order *models.Order) (*models.Order, error)
	GetAll(userID int32) (*[]models.Order, error)
	GetOrderProductsByID(id int32) (orderProducts []models.OrderProducts, err error)
}

type ProductRepository

type ProductRepository struct {
	// contains filtered or unexported fields
}

func NewProductRepository

func NewProductRepository(db *sql.DB) *ProductRepository

func (ProductRepository) Create

func (p ProductRepository) Create(product *models.Product) (*models.Product, error)

func (ProductRepository) GetAll

func (p ProductRepository) GetAll() (*[]models.Product, error)

func (ProductRepository) GetByID

func (p ProductRepository) GetByID(id int) (*models.Product, error)

func (ProductRepository) GetByName

func (p ProductRepository) GetByName(name string) (int32, error)

func (ProductRepository) GetTypes

func (p ProductRepository) GetTypes() (*[]models.ProductTypes, error)

func (ProductRepository) GetTypesBySupplier

func (p ProductRepository) GetTypesBySupplier(supplierID int32) (*[]models.ProductTypes, error)

func (ProductRepository) Update

func (p ProductRepository) Update(product *models.Product) (*models.Product, error)

type ProductRepositoryI

type ProductRepositoryI interface {
	Create(product *models.Product) (*models.Product, error)
	GetAll() (*[]models.Product, error)
	GetTypes() (*[]models.ProductTypes, error)
	GetTypesBySupplier(supplierID int32) (*[]models.ProductTypes, error)
	GetByName(name string) (int32, error)
	Update(product *models.Product) (*models.Product, error)
}

type SupplierRepository

type SupplierRepository struct {
	// contains filtered or unexported fields
}

func NewSupplierRepository

func NewSupplierRepository(db *sql.DB) *SupplierRepository

func (SupplierRepository) Create

func (s SupplierRepository) Create(supplier *models.Supplier) (*models.Supplier, error)

func (SupplierRepository) DeleteUnnecessary

func (s SupplierRepository) DeleteUnnecessary(period int) error

func (SupplierRepository) GetAll

func (s SupplierRepository) GetAll() (*[]models.Supplier, error)

func (SupplierRepository) GetByName

func (s SupplierRepository) GetByName(name string) (int32, error)

func (SupplierRepository) GetTypes

func (s SupplierRepository) GetTypes() (*[]models.SupplierTypes, error)

func (SupplierRepository) Update

func (s SupplierRepository) Update(supplier *models.Supplier) (*models.Supplier, error)

type SupplierRepositoryI

type SupplierRepositoryI interface {
	Create(supplier *models.Supplier) (*models.Supplier, error)
	GetAll() (*[]models.Supplier, error)
	GetByName(name string) (int32, error)
	GetTypes() (*[]models.SupplierTypes, error)
	Update(supplier *models.Supplier) (*models.Supplier, error)
	DeleteUnnecessary(period int) error
}

type SupplierRepositoryMock

type SupplierRepositoryMock struct {
	// contains filtered or unexported fields
}

func NewSupplierRepositoryMock

func NewSupplierRepositoryMock(db *sql.DB) *SupplierRepositoryMock

func (SupplierRepositoryMock) Create

func (s SupplierRepositoryMock) Create(supplier *models.Supplier) (*models.Supplier, error)

func (SupplierRepositoryMock) DeleteUnnecessary

func (s SupplierRepositoryMock) DeleteUnnecessary(period int) error

func (SupplierRepositoryMock) GetAll

func (s SupplierRepositoryMock) GetAll() (*[]models.Supplier, error)

func (SupplierRepositoryMock) GetByID

func (s SupplierRepositoryMock) GetByID(id int) (*models.Supplier, error)

func (SupplierRepositoryMock) GetByName

func (s SupplierRepositoryMock) GetByName(name string) (int32, error)

func (SupplierRepositoryMock) Update

func (s SupplierRepositoryMock) Update(supplier *models.Supplier) (*models.Supplier, error)

type TokensRepository

type TokensRepository struct {
	// contains filtered or unexported fields
}

func NewTokensRepository

func NewTokensRepository(db *sql.DB) *TokensRepository

func (*TokensRepository) CreateUid

func (u *TokensRepository) CreateUid(userID int32, uid models.CachedTokens) error

func (*TokensRepository) DeleteUid

func (u *TokensRepository) DeleteUid(userID int32) error

func (*TokensRepository) GetUidByID

func (u *TokensRepository) GetUidByID(claims *helper.JwtCustomClaims) (*models.CachedTokens, error)

func (*TokensRepository) UpdateUid

func (u *TokensRepository) UpdateUid(userID int32, uid models.CachedTokens) error

type TokensRepositoryI

type TokensRepositoryI interface {
	CreateUid(userID int32, uid models.CachedTokens) error
	GetUidByID(claims *helper.JwtCustomClaims) (*models.CachedTokens, error)
	UpdateUid(userID int32, uid models.CachedTokens) error
	DeleteUid(userID int32) error
}

type TokensRepositoryMock

type TokensRepositoryMock struct {
	// contains filtered or unexported fields
}

func NewTokensRepositoryMock

func NewTokensRepositoryMock(db *sql.DB) *TokensRepositoryMock

func (*TokensRepositoryMock) CreateUid

func (u *TokensRepositoryMock) CreateUid(userID int32, uid models.CachedTokens) error

func (*TokensRepositoryMock) DeleteUid

func (u *TokensRepositoryMock) DeleteUid(userID int32) error

func (*TokensRepositoryMock) GetUidByID

func (*TokensRepositoryMock) UpdateUid

func (u *TokensRepositoryMock) UpdateUid(userID int32, uid models.CachedTokens) error

type UserRepository

type UserRepository struct {
	// contains filtered or unexported fields
}

func NewUserRepository

func NewUserRepository(db *sql.DB) *UserRepository

func (*UserRepository) Create

func (u *UserRepository) Create(user *models.User) (*models.User, error)

func (*UserRepository) EmailExist

func (u *UserRepository) EmailExist(email string) (int, error)

func (*UserRepository) GetByEmail

func (u *UserRepository) GetByEmail(email string) (*models.User, error)

func (*UserRepository) GetByID

func (u *UserRepository) GetByID(id int32) (*models.User, error)

type UserRepositoryI

type UserRepositoryI interface {
	Create(user *models.User) (*models.User, error)
	GetByEmail(email string) (*models.User, error)
	EmailExist(email string) (int, error)
	GetByID(id int32) (*models.User, error)
}

type UserRepositoryMock

type UserRepositoryMock struct {
	// contains filtered or unexported fields
}

func NewUserRepositoryMock

func NewUserRepositoryMock(db *sql.DB) *UserRepositoryMock

func (*UserRepositoryMock) Create

func (u *UserRepositoryMock) Create(user *models.User) (*models.User, error)

func (*UserRepositoryMock) Delete

func (u *UserRepositoryMock) Delete(id int32) error

func (*UserRepositoryMock) EmailExist

func (u *UserRepositoryMock) EmailExist(email string) (int, error)

func (*UserRepositoryMock) GetAll

func (u *UserRepositoryMock) GetAll() (*[]models.User, error)

func (*UserRepositoryMock) GetByEmail

func (u *UserRepositoryMock) GetByEmail(email string) (*models.User, error)

func (*UserRepositoryMock) GetByID

func (u *UserRepositoryMock) GetByID(id int32) (*models.User, error)

func (*UserRepositoryMock) Update

func (u *UserRepositoryMock) Update(user *models.User) (*models.User, error)

Jump to

Keyboard shortcuts

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