productrecord

package
v0.0.0-...-e85e4ab Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GETALL = `` /* 139-byte string literal not displayed */

	GETBYID = `` /* 185-byte string literal not displayed */

	STORE = `INSERT INTO product_records (last_update_date, purchase_price,
				sale_price, product_id) VALUES (?, ?, ?, ?)`
)
View Source
const (
	ERROR_INEXISTENT_PRODUCT     = "the product id doesn`t exist"
	ERROR_WRONG_LAST_UPDATE_DATE = "the last update date must be greater than the system time"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ProductRecord

type ProductRecord struct {
	ID             int     `json:"id"`
	LastUpdateDate string  `json:"last_update_date" validate:"required"`
	PurchasePrice  float64 `json:"purchase_price" validate:"required"`
	SalePrice      float64 `json:"sale_price" validate:"required,gt=0"`
	ProductId      int     `json:"product_id" validate:"required,gt=0"`
}

type ProductRecordGet

type ProductRecordGet struct {
	ProductId    int    `json:"product_id"`
	Description  string `json:"description"`
	RecordsCount int64  `json:"records_count"`
}

type Repository

type Repository interface {
	Store(ctx context.Context, prod ProductRecord) (ProductRecord, error)
	GetById(ctx context.Context, id int) (ProductRecordGet, error)
	GetAll(ctx context.Context) ([]ProductRecordGet, error)
}

func NewRepository

func NewRepository(db *sql.DB) Repository

type Service

type Service interface {
	Store(ctx context.Context, prod ProductRecord) (ProductRecord, error)
	GetAll(ctx context.Context) ([]ProductRecordGet, error)
	GetById(ctx context.Context, id int) (ProductRecordGet, error)
}

func NewService

func NewService(r Repository, productsService products.Service) Service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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