articles

package
Version: 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 Article

type Article 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) CreateArticle

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

func (*Handler) DeleteArticle

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

func (*Handler) GenerateRoute

func (h *Handler) GenerateRoute()

func (*Handler) GetAllArticle

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

func (*Handler) GetArticle

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

func (*Handler) UpdateArticle

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

type Repository

type Repository interface {
	GetAllArticle(ctx context.Context) ([]Article, error)
	GetArticle(ctx context.Context, id int32) (*Article, error)
	CreateArticle(ctx context.Context, data Article) error
	UpdateArticle(ctx context.Context, data Article) error
	DeleteArticle(ctx context.Context, id int32) error
}

func NewRepository

func NewRepository(conn *gorm.DB) Repository

type Usecase

type Usecase interface {
	GetAllArticle(ctx context.Context) ([]Article, error)
	GetArticle(ctx context.Context, id int32) (*Article, error)
	CreateArticle(ctx context.Context, data Article) error
	UpdateArticle(ctx context.Context, data Article) error
	DeleteArticle(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
t or T : Toggle theme light dark auto
y or Y : Canonical URL