article

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler is friend web handler

func New

func New(s service, l glog.Logger) *Handler

New return new rest api friend handler

func (*Handler) List

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

func (*Handler) View

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

type MongoRepository

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

MongoRepository is MongoDB implementation of repository

func NewMongoRepository

func NewMongoRepository(s *mgo.Session) *MongoRepository

NewMongoRepository return new MongoDB repository

func (*MongoRepository) Create

func (r *MongoRepository) Create(ctx context.Context, a *types.Article) error

Create create new article

func (*MongoRepository) Delete

func (r *MongoRepository) Delete(ctx context.Context, id string) error

Delete delete the given article from database

func (*MongoRepository) FindAll

func (r *MongoRepository) FindAll(ctx context.Context, offset, limit int) ([]*types.Article, error)

FindAll return all articles

func (*MongoRepository) FindByCreatedByID

func (r *MongoRepository) FindByCreatedByID(ctx context.Context, id string) ([]*types.Article, error)

func (*MongoRepository) FindByCreatedTime

func (r *MongoRepository) FindByCreatedTime(ctx context.Context, from time.Time, to time.Time) ([]*types.Article, error)

func (*MongoRepository) Get

func (r *MongoRepository) Get(ctx context.Context, id string) (*types.Article, error)

Get return article base on given id

func (*MongoRepository) Increase

func (r *MongoRepository) Increase(ctx context.Context, id string, field string, val interface{}) error

func (*MongoRepository) Update

func (r *MongoRepository) Update(ctx context.Context, id string, a *types.Article) error

Update update existing article

type Repository

type Repository interface {
	FindAll(ctx context.Context, offset, limit int) ([]*types.Article, error)
	Increase(ctx context.Context, id string, field string, val interface{}) error
}

Repository is an interface of an article repository

type Service

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

Service is an article service

func NewService

func NewService(r Repository, l glog.Logger) *Service

NewService return a new article service

func (*Service) Create

func (s *Service) Create(ctx context.Context, a *types.Article) error

Create create a new article

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id string) error

Delete delete the given article

func (*Service) FindAll

func (s *Service) FindAll(ctx context.Context, offset, limit int) ([]*types.Article, error)

FindAll return all articles

func (*Service) Get

func (s *Service) Get(ctx context.Context, id string) (*types.Article, error)

func (*Service) Update

func (s *Service) Update(ctx context.Context, id string, a *types.Article) error

Update the existing article

func (*Service) View

func (s *Service) View(ctx context.Context, id string) error

Jump to

Keyboard shortcuts

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