product

package
v0.0.0-...-7f62264 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category struct {
	ID       int32
	Category string
	Slug     string
	ParentID *int32
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type GetProductAttributesByProductIDRow

type GetProductAttributesByProductIDRow struct {
	AttributeName   string
	AttributeValues []string
}

type GetProductByIDRow

type GetProductByIDRow struct {
	Product        Product
	SellerStore    SellerStore
	ProductPricing ProductPricing
}

type GetSKUsByProductIDRow

type GetSKUsByProductIDRow struct {
	SkuID           int64
	ProductID       int64
	Sku             string
	QuantityInStock int32
	HasSepPricing   bool
	ImageRefs       []int16
	SkuCreatedAt    pgtype.Timestamptz
	SkuUpdatedAt    pgtype.Timestamptz
	Attributes      []byte
}

type ImageUrls

type ImageUrls map[int]string

func (*ImageUrls) Scan

func (i *ImageUrls) Scan(src any) error

func (ImageUrls) Value

func (i ImageUrls) Value() (driver.Value, error)

type NullProductStatus

type NullProductStatus struct {
	ProductStatus ProductStatus
	Valid         bool // Valid is true if ProductStatus is not NULL
}

func (*NullProductStatus) Scan

func (ns *NullProductStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullProductStatus) Value

func (ns NullProductStatus) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullUserStatus

type NullUserStatus struct {
	UserStatus UserStatus
	Valid      bool // Valid is true if UserStatus is not NULL
}

func (*NullUserStatus) Scan

func (ns *NullUserStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullUserStatus) Value

func (ns NullUserStatus) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Product

type Product struct {
	ID         int64
	StoreID    int32
	CategoryID int32
	Name       string
	Brand      *string
	Slug       string
	ShortInfo  []string
	ImageUrls  ImageUrls
	Specs      Specs
	Status     ProductStatus
	CreatedAt  pgtype.Timestamptz
	UpdatedAt  pgtype.Timestamptz
}

type ProductAttribute

type ProductAttribute struct {
	ID        int64
	ProductID int64
	Attribute string
}

type ProductPricing

type ProductPricing struct {
	ProductID        int64
	BasePrice        decimal.Decimal
	CurrencyCode     string
	DiscountLevel    decimal.Decimal
	DiscountedAmount decimal.Decimal
	IsOnSale         bool
}

type ProductRating

type ProductRating struct {
	ID        int64
	ProductID int64
	UserID    *int64
	Rating    int16
	Review    *string
	ImageUrls []string
	CreatedAt pgtype.Timestamptz
}

type ProductStatus

type ProductStatus string
const (
	ProductStatusDraft           ProductStatus = "Draft"
	ProductStatusPendingApproval ProductStatus = "PendingApproval"
	ProductStatusActive          ProductStatus = "Active"
)

func (*ProductStatus) Scan

func (e *ProductStatus) Scan(src interface{}) error

type ProductsByCategoryRow

type ProductsByCategoryRow struct {
	ID               int64
	Name             string
	Slug             string
	ThumbImg         string
	BasePrice        decimal.Decimal
	DiscountedAmount decimal.Decimal
	CurrencyCode     string
	Count            int64
}

type Querier

type Querier interface {
	CreateProduct(ctx context.Context, storeID int32, categoryID int32, name string, brand *string, slug string, shortInfo []string, imageUrls ImageUrls, specs Specs, status ProductStatus) (*Product, error)
	CreateProductAttribute(ctx context.Context, productID int64, attribute string) (int64, error)
	CreateProductPricing(ctx context.Context, productID int64, basePrice decimal.Decimal, currencyCode string, discountLevel decimal.Decimal, discountedAmount decimal.Decimal, isOnSale bool) error
	CreateSKU(ctx context.Context, productID int64, sku string, quantityInStock int32, hasSepPricing bool, imageRefs []int16) (int64, error)
	CreateSKUPricing(ctx context.Context, skuID int64, basePrice decimal.Decimal, currencyCode string, discountLevel decimal.Decimal, discountedAmount decimal.Decimal, isOnSale bool) (int64, error)
	CreateSKUProductAttributeValues(ctx context.Context, skuID int64, productAttributeID int64, attributeValue string) error
	GetProductAttributesByProductID(ctx context.Context, productID int64) ([]*GetProductAttributesByProductIDRow, error)
	GetProductByID(ctx context.Context, id int64) (*GetProductByIDRow, error)
	GetProductsByCategoryIDs(ctx context.Context, offset int32, limit int32, leafCategoryIds []int32) ([]*Product, error)
	GetSKUsByProductID(ctx context.Context, productID int64) ([]*GetSKUsByProductIDRow, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateProduct

func (q *Queries) CreateProduct(ctx context.Context, storeID int32, categoryID int32, name string, brand *string, slug string, shortInfo []string, imageUrls ImageUrls, specs Specs, status ProductStatus) (*Product, error)

func (*Queries) CreateProductAttribute

func (q *Queries) CreateProductAttribute(ctx context.Context, productID int64, attribute string) (int64, error)

func (*Queries) CreateProductPricing

func (q *Queries) CreateProductPricing(ctx context.Context, productID int64, basePrice decimal.Decimal, currencyCode string, discountLevel decimal.Decimal, discountedAmount decimal.Decimal, isOnSale bool) error

func (*Queries) CreateSKU

func (q *Queries) CreateSKU(ctx context.Context, productID int64, sku string, quantityInStock int32, hasSepPricing bool, imageRefs []int16) (int64, error)

func (*Queries) CreateSKUPricing

func (q *Queries) CreateSKUPricing(ctx context.Context, skuID int64, basePrice decimal.Decimal, currencyCode string, discountLevel decimal.Decimal, discountedAmount decimal.Decimal, isOnSale bool) (int64, error)

func (*Queries) CreateSKUProductAttributeValues

func (q *Queries) CreateSKUProductAttributeValues(ctx context.Context, skuID int64, productAttributeID int64, attributeValue string) error

func (*Queries) GetProductAttributesByProductID

func (q *Queries) GetProductAttributesByProductID(ctx context.Context, productID int64) ([]*GetProductAttributesByProductIDRow, error)

func (*Queries) GetProductByID

func (q *Queries) GetProductByID(ctx context.Context, id int64) (*GetProductByIDRow, error)

func (*Queries) GetProductsByCategoryIDs

func (q *Queries) GetProductsByCategoryIDs(ctx context.Context, offset int32, limit int32, leafCategoryIds []int32) ([]*Product, error)

func (*Queries) GetSKUsByProductID

func (q *Queries) GetSKUsByProductID(ctx context.Context, productID int64) ([]*GetSKUsByProductIDRow, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type Role

type Role struct {
	ID   int16
	Role string
}

type SellerStore

type SellerStore struct {
	ID          int32
	PublicID    string
	SellerID    int64
	Name        string
	Description string
	CreatedAt   pgtype.Timestamptz
	UpdatedAt   pgtype.Timestamptz
}

type Session

type Session struct {
	Token  string
	Data   []byte
	Expiry pgtype.Timestamptz
}

type Sku

type Sku struct {
	ID              int64
	ProductID       int64
	Sku             string
	QuantityInStock int32
	HasSepPricing   bool
	ImageRefs       []int16
	CreatedAt       pgtype.Timestamptz
	UpdatedAt       pgtype.Timestamptz
}

type SkuPricing

type SkuPricing struct {
	SkuID            int64
	BasePrice        decimal.Decimal
	CurrencyCode     string
	DiscountLevel    decimal.Decimal
	DiscountedAmount decimal.Decimal
	IsOnSale         bool
}

type SkuProductAttributeValue

type SkuProductAttributeValue struct {
	SkuID              int64
	ProductAttributeID int64
	AttributeValue     string
}

type Specs

type Specs map[string]string

func (*Specs) Scan

func (i *Specs) Scan(src any) error

func (Specs) Value

func (i Specs) Value() (driver.Value, error)

type Store

type Store interface {
	Querier
	GetProductsByLeafCategoryID(ctx context.Context, categoryID int32, p anor.GetProductsByCategoryParams) ([]ProductsByCategoryRow, error)
	GetProductsByLeafCategoryIDs(ctx context.Context, categoryID []int32, p anor.GetProductsByCategoryParams) ([]ProductsByCategoryRow, error)
	WithTx(ctx context.Context, fn func(tx pgx.Tx) error) error
}

func NewStore

func NewStore(pool *pgxpool.Pool) Store

type User

type User struct {
	ID          int64
	Email       string
	Password    string
	PhoneNumber *string
	FullName    string
	Status      UserStatus
	Otp         *string
	OtpExpiry   *int64
	CreatedAt   pgtype.Timestamptz
	UpdatedAt   pgtype.Timestamptz
}

type UserRole

type UserRole struct {
	UserID int64
	RoleID int16
}

type UserStatus

type UserStatus string
const (
	UserStatusBlocked             UserStatus = "Blocked"
	UserStatusRegistrationPending UserStatus = "RegistrationPending"
	UserStatusActive              UserStatus = "Active"
	UserStatusInactice            UserStatus = "Inactice"
)

func (*UserStatus) Scan

func (e *UserStatus) Scan(src interface{}) error

Jump to

Keyboard shortcuts

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