Documentation ¶
Index ¶
Constants ¶
View Source
const ( GETALL = "SELECT * FROM products" GETBYID = "SELECT * FROM products WHERE id=?" STORE = `` /* 234-byte string literal not displayed */ UPDATE = `` /* 227-byte string literal not displayed */ DELETE = "DELETE FROM products WHERE id=?" PRODUCT_CODE = `SELECT product_code FROM products WHERE id != ? and product_code = ?` PRODUCT_TYPE = `SELECT * FROM product_types WHERE id=?` )
View Source
const ( ERROR_INEXISTENT_SELLER = "the seller id doesn`t exist" ERROR_INEXISTENT_PRODUCT_TYPE = "the product type id doesn`t exist" ERROR_UNIQUE_PRODUCT_CODE = "the product code must be unique" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Product ¶
type Product struct { ID int `json:"id"` ProductCode string `json:"product_code" validate:"required"` Description string `json:"description" validate:"required"` Width float64 `json:"width" validate:"required,gt=0"` Height float64 `json:"height" validate:"required,gt=0"` Length float64 `json:"length" validate:"required,gt=0"` NetWeight float64 `json:"net_weight" validate:"required,gt=0"` ExpirationRate float64 `json:"expiration_rate" validate:"required"` RecommendedFreezingTemperature float64 `json:"recommended_freezing_temperature" validate:"required,gt=0"` FreezingRate float64 `json:"freezing_rate" validate:"required,gt=0"` ProductTypeId int `json:"product_type_id" validate:"required,gt=0"` SellerId int `json:"seller_id"` }
type Repository ¶
type Repository interface { Store(ctx context.Context, prod Product) (Product, error) GetAll(ctx context.Context) ([]Product, error) GetById(ctx context.Context, id int) (Product, error) Update(ctx context.Context, prod Product, id int) (Product, error) Delete(ctx context.Context, id int) error CheckProductCode(ctx context.Context, id int, productCode string) bool CheckProductType(ctx context.Context, productTypeId int) bool }
func NewRepository ¶
func NewRepository(db *sql.DB) Repository
type Service ¶
type Service interface { Store(ctx context.Context, prod Product) (Product, error) GetAll(ctx context.Context) ([]Product, error) GetById(ctx context.Context, id int) (Product, error) Update(ctx context.Context, prod Product, id int) (Product, error) Delete(ctx context.Context, id int) error }
func NewService ¶
func NewService(r Repository, sellerService seller.Service) Service
Click to show internal directories.
Click to hide internal directories.