repos

package
v0.0.0-...-f5ca578 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CustomerLoginError  = "incorrect username and password combination"
	CustomerUpdateError = "can't update customer, missing customer ID"
)
View Source
const (
	CustomerPasswordResetUpdateError = "can't update customer password reset, missing customer ID"
	GetCustomerByPasswordResetToken  = "could not find valid passsword reset token: %s"
)
View Source
const (
	CustomerAddressUpdateError = "can't update customer address"
)

Variables

View Source
var (
	ErrNotFound = sql.ErrNoRows
)

Functions

func BuildOrderBy

func BuildOrderBy(on string, allowedFields map[string]string) (orderBy string, err error)

Types

type Asset

type Asset interface {
	Exists() bool
	Deleted() bool
	Create(asset *models.Asset) error
	CreateTx(asset *models.Asset, tx *sql.Tx) error
	Update(asset *models.Asset) error
	Save() error
	Upsert() error
	Delete(id int64) error
	GetAssetById(id int64) (res *models.Asset, err error)
	GetAssetByProductIDKind(productId int64, kind int) (res []*models.Asset, err error)
	AssetExists(storeId int64, name string) (res bool, err error)
}

type Cart

type Cart interface {
	SetCart(cart *models.Cart)
	Exists() bool
	Deleted() bool
	Create(cart *models.Cart) (err error)
	Update(cart *models.Cart) (err error)
	Delete(cartId string) error

	GetByCartId(cartId uuid.UUID) (res *models.Cart, err error)
}

type CartItem

type CartItem interface {
	SetCartItem(cartItem *models.CartItem)
	Exists() bool
	Deleted() bool
	Create(cartItem *models.CartItem) error
	Update(cartItem *models.CartItem) error
	Save(cartItem *models.CartItem) error
	Upsert(cartItem *models.CartItem) error
	Delete(cartId uuid.UUID, sku string, force bool) error

	GetByCartId(cartId uuid.UUID) ([]*models.CartItem, error)
	ClearItems(cartId uuid.UUID, force bool) (err error)
	AddItem(cartId uuid.UUID, item *models.CartItem) (res *models.CartItem, err error)
	UpdateQuantity(cartId uuid.UUID, sku string, quantity int) (res *models.CartItem, err error)
}

type Category

type Category interface {
	Exists() bool
	Deleted() bool
	Create(cat *models.Category) error
	Update(cat *models.Category) error
	Save() error
	Upsert() error
	Delete(id int64) error
	GetCategoryBySlug(storeId int64, slug string) (*models.Category, error)
	GetCategoryById(id int64) (*models.Category, error)
	GetAllCategories(storeId int64) (res *getAllCategoriesResponse, err error)
}

type CategoryPair

type CategoryPair struct {
	Slug string
	Name string
}

type CategoryPairs

type CategoryPairs struct {
	Pairs []CategoryPair
}

func (*CategoryPairs) Scan

func (c *CategoryPairs) Scan(src interface{}) error

type Customer

type Customer interface {
	Exists() bool
	Deleted() bool
	Create(customer *models.Customer) error
	Update(customer *models.Customer) error
	Save() error
	Upsert() error
	Delete(id int64) error
	Login(storeId int64, email, password string) (res *models.Customer, err error)
	GetCustomerByEmail(storeId int64, email string) (res *models.Customer, err error)
}

type CustomerAddress

type CustomerAddress interface {
	Exists() bool
	Deleted() bool
	Create(address *models.CustomerAddress) error
	Update(address *models.CustomerAddress) error
	Save() error
	Upsert() error
	Delete(id int64) error
	GetCustomerAddressesByCustomerIdKind(customerId int64, kind models.AddressKind) ([]*models.CustomerAddress, error)
}

type CustomerPasswordReset

type CustomerPasswordReset interface {
	Exists() bool
	Deleted() bool
	Create(customerPasswordReset *models.CustomerPasswordReset) error
	Update(customerPasswordReset *models.CustomerPasswordReset) error
	Save() error
	Upsert() error
	Redeem(token string) error
	GetCustomerByPasswordResetToken(token string) (res *models.Customer, err error)
}

type ErrorCode

type ErrorCode int
const (
	SqlErrorCode ErrorCode = iota
	SelectErrorCode
	SaveErrorCode
	UpdateErrorCode
	UpsertErrorCode
	DeleteErrorCode
	HashPasswordErrorCode
	CustomerLoginErrorCode
	GetCustomerByEmailErrorCode
	GetStoreByIdErrorCode
	RedeemPasswordResetErrorCode
	SelectCustomerPasswordResetByTokenErrorCode
	SelectCustomerErrorCode
)

type InventoryBrand

type InventoryBrand interface {
	Exists() bool
	Deleted() bool
	Create(ii *models.InventoryBrand) error
	Update(ii *models.InventoryBrand) error
	Save() error
	Upsert() error
	Delete(id int64) error
}

type InventoryItem

type InventoryItem interface {
	Exists() bool
	Deleted() bool
	Create(ii *models.InventoryItem) error
	Update(ii *models.InventoryItem) error
	Save() error
	Upsert() error
	Delete(id int64) error
}

type InventoryStock

type InventoryStock interface {
	Exists() bool
	Deleted() bool
	Create(ii *models.InventoryStock) error
	Update(ii *models.InventoryStock) error
	Save() error
	Upsert() error
	Delete(id int64) error
}

type InventorySupplier

type InventorySupplier interface {
	Exists() bool
	Deleted() bool
	Create(ii *models.InventorySupplier) error
	Update(ii *models.InventorySupplier) error
	Save() error
	Upsert() error
	Delete(id int64) error
}

type OthersBought

type OthersBought interface {
	Exists() bool
	Deleted() bool
	Create(prod *models.Product) error
	Update(prod *models.Product) error
	Save() error
	Upsert() error
	Delete(id int64) error
}

type PagingStats

type PagingStats struct {
	TotalRecords int64 `db:"total_records" json:"total_records"`
	TotalPages   int64 `db:"total_pages" json:"total_pages"`
}

func (*PagingStats) Calc

func (s *PagingStats) Calc(pageSize int64) *PagingStats

type PostgresConfig

type PostgresConfig struct {
	DataSourceName               string
	MaxOpenConnections           int
	MaxIdleConnections           int
	MaxConnectionLifetimeMinutes int
}

type Product

type Product interface {
	Exists() bool
	Deleted() bool
	Create(prod *models.Product) error
	Update(prod *models.Product) error
	Save() error
	Upsert() error
	Delete(id int64) error
	GetProductById(productID int64) (res *productResponse, err error)
	GetProductBySku(storeId int64, sku string) (res *productResponse, err error)
	GetProductBySlug(storeId int64, slug string) (res *productResponse, err error)
	GetProductsByCategoryId(storeId, categoryID, currentPage, pageSize int64, filter string) (
		res *getProductsByCategoryResponse,
		err error,
	)
	GetProductsByCategorySlug(storeId int64, categorySlug string, currentPage, pageSize int64, filter string) (
		res *getProductsByCategoryResponse,
		err error,
	)
	GetAllProducts(storeId, currentPage, pageSize int64, filter string) (
		res *getAllProductsResponse,
		err error,
	)
}

type Repo

type Repo interface {
	GetRawDB() *sqlx.DB
	// Repos
	Asset() Asset
	Cart() Cart
	CartItem() CartItem
	Category() Category
	Customer() Customer
	CustomerAddress() CustomerAddress
	CustomerPasswordReset() CustomerPasswordReset
	InventoryBrand() InventoryBrand
	InventoryItem() InventoryItem
	InventoryStock() InventoryStock
	InventorySupplier() InventorySupplier
	Product() Product
	OthersBought() OthersBought
	SimilarProducts() SimilarProducts
	Store() Store
	StoreSetting() StoreSetting
	User() User

	Begin() (*sql.Tx, error)
	Rollback(tx *sql.Tx) error
	Commit(tx *sql.Tx) error
}

func NewRepo

func NewRepo(c *PostgresConfig) Repo

type RepoError

type RepoError struct {
	StatusCode ErrorCode
	Err        error
}

func (*RepoError) Error

func (r *RepoError) Error() string

type SimilarProducts

type SimilarProducts interface {
	Exists() bool
	Deleted() bool
	Create(prod *models.Product) error
	Update(prod *models.Product) error
	Save() error
	Upsert() error
	Delete(id int64) error
}

type Store

type Store interface {
	Exists() bool
	Deleted() bool
	Create(store *models.Store) error
	Update(store *models.Store) error
	Save() error
	Upsert() error
	Delete(id int64) error
	GetStoreById(storeId int64) (*models.Store, error)
}

type StoreSetting

type StoreSetting interface {
	Exists() bool
	Deleted() bool
	Create(store *models.StoreSetting) error
	Update(store *models.StoreSetting) error
	Save() error
	Upsert() error
	Delete(id int64) error
	GetStoreSettingById(storeId int64) (*models.StoreSetting, error)
}

type User

type User interface {
	Exists() bool
	Deleted() bool
	Create(user *models.User) error
	Update(user *models.User) error
	Save() error
	Upsert() error
	Delete(id int64) error
	Login(username, password string) (res *models.User, err error)
	GetAllPermissionGroups(currentPage, pageSize int64, sortOn string) (res *getAllPermissionGroupsResponse, err error)
	GetAllUsers(currentPage, pageSize int64, sortOn string) (res *getAllUsersResponse, err error)
}

Directories

Path Synopsis
Package mock_repos is a generated GoMock package.
Package mock_repos is a generated GoMock package.

Jump to

Keyboard shortcuts

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