books

package
v0.0.0-...-8328a67 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDB = errors.New("Database error")
View Source
var ErrNotFound = errors.New("Data not found")

Functions

This section is empty.

Types

type Book

type Book struct {
	Id     int32  `json:"id" gorm:"column:id;primaryKey"`
	Title  string `json:"title" gorm:"column:title"`
	Author string `json:"author" gorm:"column:author"`

	CreatedAt time.Time `json:"-" gorm:"created_at"`
	UpdatedAt time.Time `json:"-" gorm:"updated_at"`
}

type Handler

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

func NewHandler

func NewHandler(r *gin.RouterGroup, uc Usecase) *Handler

func (*Handler) CreateBook

func (h *Handler) CreateBook(c *gin.Context)

func (*Handler) DeleteBook

func (h *Handler) DeleteBook(c *gin.Context)

func (*Handler) GenerateRoute

func (h *Handler) GenerateRoute()

func (*Handler) GetAllBook

func (h *Handler) GetAllBook(c *gin.Context)

func (*Handler) GetBook

func (h *Handler) GetBook(c *gin.Context)

func (*Handler) UpdateBook

func (h *Handler) UpdateBook(c *gin.Context)

type Repository

type Repository interface {
	GetAllBook(ctx context.Context) ([]Book, error)
	GetBook(ctx context.Context, id int32) (*Book, error)
	CreateBook(ctx context.Context, data Book) error
	UpdateBook(ctx context.Context, data Book) error
	DeleteBook(ctx context.Context, id int32) error
}

func NewRepository

func NewRepository(conn *gorm.DB) Repository

type Usecase

type Usecase interface {
	GetAllBook(ctx context.Context) ([]Book, error)
	GetBook(ctx context.Context, id int32) (*Book, error)
	CreateBook(ctx context.Context, data Book) error
	UpdateBook(ctx context.Context, data Book) error
	DeleteBook(ctx context.Context, id int32) error
}

func NewUsecase

func NewUsecase(repo Repository) Usecase

Jump to

Keyboard shortcuts

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