product

package
v0.0.0-...-25e78fc Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(router fiber.Router, db *sqlx.DB)

Types

type CreateProductRequestPayload

type CreateProductRequestPayload struct {
	Name  string `json:"name"`
	Stock int16  `json:"stock"`
	Price int    `json:"price"`
}

type ListProductRequestPayload

type ListProductRequestPayload struct {
	Cursor int `query:"cursor" json:"cursor"`
	Size   int `query:"size" json:"size"`
}

func (ListProductRequestPayload) GenerateDefaultValue

func (l ListProductRequestPayload) GenerateDefaultValue() ListProductRequestPayload

type Product

type Product struct {
	Id        int       `db:"id"`
	SKU       string    `db:"sku"`
	Name      string    `db:"name"`
	Stock     int16     `db:"stock"`
	Price     int       `db:"price"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

func NewProductFromCreateProductRequest

func NewProductFromCreateProductRequest(req CreateProductRequestPayload) Product

func (Product) Validate

func (p Product) Validate() (err error)

func (Product) ValidateName

func (p Product) ValidateName() (err error)

func (Product) ValidatePrice

func (p Product) ValidatePrice() (err error)

func (Product) ValidateStock

func (p Product) ValidateStock() (err error)

type ProductDetailResponse

type ProductDetailResponse struct {
	Id        int       `json:"id"`
	SKU       string    `json:"sku"`
	Name      string    `json:"name"`
	Stock     int16     `json:"stock"`
	Price     int       `json:"price"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type ProductListResponse

type ProductListResponse struct {
	Id    int    `json:"id"`
	SKU   string `json:"sku"`
	Name  string `json:"name"`
	Stock int16  `json:"stock"`
	Price int    `json:"price"`
}

func NewProductListResponseFromEntity

func NewProductListResponseFromEntity(products []Product) []ProductListResponse

type ProductPagination

type ProductPagination struct {
	Cursor int `json:"cursor"`
	Size   int `json:"size"`
}

func NewProductPaginationFromListProductRequest

func NewProductPaginationFromListProductRequest(req ListProductRequestPayload) ProductPagination

type Repository

type Repository interface {
	CreateProduct(ctx context.Context, model Product) (err error)
	GetAllProductsWithPaginationCursor(ctx context.Context, model ProductPagination) (products []Product, err error)
	GetProductBySKU(ctx context.Context, sku string) (model Product, err error)
}

Jump to

Keyboard shortcuts

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