product

package
v0.0.0-...-df4534a Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIDNotFound = errors.New("el producto no contiene un ID")
)

Functions

This section is empty.

Types

type Model

type Model struct {
	ID           uint
	Name         string
	Observations string
	Price        int
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

Model of product

func (*Model) String

func (m *Model) String() string

type Models

type Models []*Model

Models slice of Model

func (Models) String

func (m Models) String() string

type Service

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

Service of product

func NewService

func NewService(s Storage) *Service

NewService return a pointer of Service

func (*Service) Create

func (s *Service) Create(m *Model) error

Create is used for create a product

func (*Service) Delete

func (s *Service) Delete(id uint) error

Delete is used for delete a product

func (*Service) GetAll

func (s *Service) GetAll() (Models, error)

GetAll is used of get all the products

func (*Service) GetByID

func (s *Service) GetByID(id uint) (*Model, error)

GetByID is used for get a product

func (*Service) Migrate

func (s *Service) Migrate() error

Migrate is used for migrate product

func (*Service) Update

func (s *Service) Update(m *Model) error

Update is used for update a product

type Storage

type Storage interface {
	Migrate() error
	Create(*Model) error
	Update(*Model) error
	GetAll() (Models, error)
	GetByID(uint) (*Model, error)
	Delete(uint) error
}

Storage interface that must implement a db storage

Jump to

Keyboard shortcuts

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