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 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
Click to show internal directories.
Click to hide internal directories.