service

package
v0.0.0-...-1e91f80 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArticleService

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

func NewArticleService

func NewArticleService(repo repository.IArticleRepository) *ArticleService

func (*ArticleService) ApplyArticleChanges

func (svc *ArticleService) ApplyArticleChanges(id string, changes *model.UpdateArticle) (*model.Article, error)

Applies a UpdateArticle-Request to an Article by its IDs and stores the updated Article back to the database.

func (*ArticleService) CreateArticleFromRequest

func (svc *ArticleService) CreateArticleFromRequest(creationRequest *model.CreateArticle) (*model.Article, error)

Creates a new Article from an CreateArticle-Request

func (*ArticleService) DeleteArticle

func (svc *ArticleService) DeleteArticle(id string) (bool, error)

Delete an Article by its ID. Returning (true, nil) when the deletion was successful.

func (*ArticleService) GetArticle

func (svc *ArticleService) GetArticle(id string) (*model.Article, error)

Returns an Article from the Database by its ID.

func (*ArticleService) ListArticles

func (svc *ArticleService) ListArticles() ([]*model.Article, error)

Returns a List of all Articles found in the Database.

func (*ArticleService) SaveArticle

func (svc *ArticleService) SaveArticle(article *model.Article) (*model.Article, error)

Saves an Article to the Database. If the Article does not already exists, it will be created.

func (*ArticleService) SubscribeArticleCreation

func (svc *ArticleService) SubscribeArticleCreation() *ArticleServiceObserver

Adds an Observer to the ArticleCreationStream. The returned object is holding a personal channel

func (*ArticleService) UnsubscribeArticleCreation

func (svc *ArticleService) UnsubscribeArticleCreation(observer *ArticleServiceObserver)

Remove an Observer from the ArticleCreationStream

type ArticleServiceObserver

type ArticleServiceObserver struct {
	CreationStream chan *model.Article
}

type IArticleService

type IArticleService interface {
	ListArticles() ([]*model.Article, error)
	GetArticle(string) (*model.Article, error)
	SaveArticle(*model.Article) (*model.Article, error)
	DeleteArticle(string) (bool, error)
	CreateArticleFromRequest(*model.CreateArticle) (*model.Article, error)
	ApplyArticleChanges(string, *model.UpdateArticle) (*model.Article, error)
	SubscribeArticleCreation() *ArticleServiceObserver
	UnsubscribeArticleCreation(*ArticleServiceObserver)
}

Jump to

Keyboard shortcuts

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