book

package
v0.0.0-...-7428172 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound  = errors.New("book is not found")
	ErrNotValid  = errors.New("book is not valid")
	ErrNotUnique = errors.New("book is not unique")
)

Functions

This section is empty.

Types

type Book

type Book struct {
	ID              int     `json:"id"`
	Isbn            string  `json:"isbn"`
	Title           string  `json:"title"`
	Author          *string `json:"author"`
	PublicationYear *string `json:"publication_year"`
	Publisher       *string `json:"publisher"`
}

type Core

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

Core manages the set of APIs for book access. Notes: Core does not maintain any state, we should use value semantic. Core is responsible for validating book data. Core is responsible for persisting book data.

func NewCore

func NewCore(sqlDB *sqlx.DB, logger *zap.SugaredLogger) Core

NewCore constructs a Core for book api access.

func (Core) Create

func (c Core) Create(ctx context.Context, nb NewBook) (Book, error)

func (Core) Query

func (c Core) Query(ctx context.Context, page int, rowsPerPage int) ([]Book, error)

func (Core) QueryByID

func (c Core) QueryByID(ctx context.Context, ID int) (Book, error)

type FieldError

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

func (FieldError) Error

func (fe FieldError) Error() string

type NewBook

type NewBook struct {
	Isbn            string `json:"isbn"`
	Title           string `json:"title"`
	Author          string `json:"author"`
	PublicationYear string `json:"publication_year"`
	Publisher       string `json:"publisher"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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