block

package
v0.0.0-...-b76d47b Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBlockNotFound        = errors.New("block not found")
	ErrBlockNotCreated      = errors.New("block not created")
	ErrBlockNotDeleted      = errors.New("block not deleted")
	ErrBlockNotUpdated      = errors.New("block not updated")
	ErrEmptyBlockName       = errors.New("empty block name")
	ErrEmptyBlockFormfactor = errors.New("empty block formfactor")
	ErrEmptyBlockType       = errors.New("empty block type")
)

Functions

This section is empty.

Types

type Block

type Block struct {
	ID         int    `json:"id"`
	Name       string `json:"name"`
	Formfactor string `json:"formfactor"`
	Type       string `json:"type"`
}

type CRUDInteractor

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

func NewCRUDInteractor

func NewCRUDInteractor(repo Repository) *CRUDInteractor

func (*CRUDInteractor) Add

func (i *CRUDInteractor) Add(block *Block) (int64, error)

func (*CRUDInteractor) Delete

func (i *CRUDInteractor) Delete(blockID int) error

func (*CRUDInteractor) Get

func (i *CRUDInteractor) Get(blockID int) (*Block, error)

func (*CRUDInteractor) GetRange

func (i *CRUDInteractor) GetRange(limit, offset int) ([]*Block, error)

func (*CRUDInteractor) Update

func (i *CRUDInteractor) Update(newBlock *Block) error

type DTO

type DTO struct {
	Name       string `json:"name"`
	Formfactor string `json:"formfactor"`
	Type       string `json:"type"`
}

func (*DTO) Validate

func (b *DTO) Validate() error

type Handler

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

func NewHandler

func NewHandler(usecases Usecases) *Handler

func (*Handler) Block

func (h *Handler) Block(w http.ResponseWriter, r *http.Request)

func (*Handler) Blocks

func (h *Handler) Blocks(w http.ResponseWriter, r *http.Request)

func (*Handler) Create

func (h *Handler) Create(w http.ResponseWriter, r *http.Request)

func (*Handler) Delete

func (h *Handler) Delete(w http.ResponseWriter, r *http.Request)

func (*Handler) Update

func (h *Handler) Update(w http.ResponseWriter, r *http.Request)

type Reader

type Reader interface {
	Find(id int) (*Block, error)
	FindRange(limit, offset int) ([]*Block, error)
}

type Repo

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

func NewSQLRepository

func NewSQLRepository(db sqlutil.SQLDatabase) *Repo

func (*Repo) Find

func (r *Repo) Find(id int) (*Block, error)

func (*Repo) FindRange

func (r *Repo) FindRange(limit, offset int) ([]*Block, error)

func (*Repo) Remove

func (r *Repo) Remove(id int) error

func (*Repo) Store

func (r *Repo) Store(b *Block) (int64, error)

func (*Repo) Update

func (r *Repo) Update(newBlock *Block) error

type Repository

type Repository interface {
	Reader
	Writer
}

type Usecases

type Usecases interface {
	Get(blockID int) (*Block, error)
	GetRange(limit, offset int) ([]*Block, error)
	Add(block *Block) (int64, error)
	Update(block *Block) error
	Delete(blockID int) error
}

type Writer

type Writer interface {
	Store(block *Block) (int64, error)
	Update(block *Block) error
	Remove(id int) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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