service

package
v0.0.0-...-372eb2b Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailedValidation = errors.New("failed validation")
	ErrNotFound         = errors.New("document not found")
)

Functions

This section is empty.

Types

type CreateArticleInput

type CreateArticleInput struct {
	Title            string            `json:"title"`
	Content          string            `json:"content"`
	Tags             []string          `json:"tags"`
	Author           string            `json:"author"`
	ValidationErrors map[string]string `json:"-"`
}

type CreateSubscriberInput

type CreateSubscriberInput struct {
	Email            string            `json:"email"`
	ValidationErrors map[string]string `json:"-"`
}

type FetchArticlesInput

type FetchArticlesInput struct {
	Title string
	Tags  []string
	models.Filters
	ValidationErrors map[string]string
}

type FetchSubscribersInput

type FetchSubscribersInput struct {
	Email string
	models.Filters
	ValidationErrors map[string]string
}

type Service

type Service struct {
	Repo *data.Repository
}

func New

func New(r *data.Repository) *Service

func (Service) CreateArticle

func (svc Service) CreateArticle(input *CreateArticleInput) (*models.Article, error)

func (Service) CreateSubscriber

func (svc Service) CreateSubscriber(input *CreateSubscriberInput) (*models.Subscriber, error)

func (*Service) DeleteArticle

func (svc *Service) DeleteArticle(id string) error

func (Service) DeleteSubscriber

func (svc Service) DeleteSubscriber(id string) error

func (*Service) GetArticleByID

func (svc *Service) GetArticleByID(id string) (*models.Article, error)

func (*Service) GetArticles

func (svc *Service) GetArticles(input *FetchArticlesInput) ([]models.Article, error)

func (Service) GetSubscribers

func (svc Service) GetSubscribers(input *FetchSubscribersInput) ([]models.Subscriber, error)

func (*Service) UpdateArticle

func (svc *Service) UpdateArticle(id string, input *UpdateArticleInput) (*models.Article, error)

type UpdateArticleInput

type UpdateArticleInput struct {
	Title            string            `bson:"title,omitempty" json:"title,omitempty"`
	Content          string            `bson:"content,omitempty" json:"content,omitempty"`
	Tags             []string          `bson:"tags,omitempty" json:"tags,omitempty"`
	Author           string            `bson:"author,omitempty" json:"author,omitempty"`
	Status           string            `bson:"status,omitempty" json:"status,omitempty"`
	ValidationErrors map[string]string `bson:"-" json:"-"`
}

Jump to

Keyboard shortcuts

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