domain

package
v0.0.0-...-5c9176d Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInternalServerError will throw if any the Internal Server Error happen
	ErrInternalServerError = errors.New("Internal Server Error")
	// ErrNotFound will throw if the requested item is not exists
	ErrNotFound = errors.New("Your requested Item is not found")
	// ErrConflict will throw if the current action already exists
	ErrConflict = errors.New("Your Item already exist")
	// ErrBadParamInput will throw if the given request-body or params is not valid
	ErrBadParamInput = errors.New("Given Param is not valid")
)

Functions

This section is empty.

Types

type Author

type Author struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Author repesent the author Model

type AuthorRepository

type AuthorRepository interface {
	// Read
	GetByID(ctx context.Context, id int64) (Author, error)
}

AuthorRepository represent the author's repository contract

type AuthorUsecase

type AuthorUsecase interface {
	// Read
	GetByID(ctx context.Context, id int64) (Author, error)
}

AuthorUsecase represent the author's usecase contract

type Post

type Post struct {
	ID        int64     `json:"id"`
	Title     string    `json:"title" validate:"required"`
	Content   string    `json:"content" validate:"required"`
	Author    Author    `json:"author"`
	UpdatedAt time.Time `json:"updated_at"`
	CreatedAt time.Time `json:"created_at"`
}

Post represent the post model

type PostRepository

type PostRepository interface {
	// Create
	Store(ctx context.Context, p *Post) error

	// Read
	Fetch(ctx context.Context, cursor string, num int64) (res []Post, nextCursor string, err error)
	GetByID(ctx context.Context, id int64) (Post, error)
	GetByTitle(ctx context.Context, title string) (Post, error)

	// Update
	Update(ctx context.Context, p *Post) error

	// Delete
	Delete(ctx context.Context, id int64) (err error)
}

PostRepository represent the post's repository contract

type PostUsecase

type PostUsecase interface {
	// Create
	Store(ctx context.Context, p *Post) error

	// Read
	Fetch(ctx context.Context, cursor string, num int64) ([]Post, string, error)
	GetByID(ctx context.Context, id int64) (Post, error)
	GetByTitle(ctx context.Context, title string) (Post, error)

	// Update
	Update(ctx context.Context, p *Post) error

	// Delete
	Delete(ctx context.Context, id int64) error
}

PostUsecase represent the post's usecase contract

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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