service

package
v2.3.19 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNewsNotFound    = apperr.New("news_not_found", apperr.WithTextTranslate(i18n.ErrNewsNotFound), apperr.WithCode(code.NotFound))
	ErrNewsListIsEmpty = apperr.New("news_list_is_empty", apperr.WithTextTranslate(i18n.ErrNewsListIsEmpty), apperr.WithCode(code.NotFound))
	ErrNewsExists      = apperr.New("news_exists_error", apperr.WithTextTranslate(i18n.ErrNewsExists), apperr.WithCode(code.InvalidArgument))
)

Functions

This section is empty.

Types

type Deps

type Deps struct {
	Repositories repository.Repositories
}

type INewsService

type INewsService interface {
	task.Consumer
	Trx(db *gorm.DB) INewsService
	List(ctx context.Context, m *model2.Meta[model.News]) error
	ExportList(ctx context.Context) ([]model.News, error)
	GetById(ctx context.Context, id int) (*model.News, error)
	Create(ctx context.Context, input NewsCreateInput) (*model.News, error)
	Update(ctx context.Context, id int, input NewsUpdateInput) error
	Delete(ctx context.Context, id int) error
}

type NewsCreateInput

type NewsCreateInput struct {
	Title   string
	Content *string
}

type NewsExport

type NewsExport struct {
	Title   string  `json:"title" csv:"title"`
	Content *string `json:"content" csv:"content"`
	UserID  int     `json:"user_id" csv:"user_id"`
}

type NewsExportInput added in v2.3.1

type NewsExportInput struct {
	Filter model2.Filter `json:"filter"`
}

type NewsImportDataInput

type NewsImportDataInput struct {
	Err     *string `json:"err,omitempty"`
	Title   string  `json:"title"`
	Content *string `json:"content"`
}

type NewsImportInput

type NewsImportInput struct {
	UserID int                   `json:"user_id"`
	Data   []NewsImportDataInput `json:"data"`
}

type NewsMassDeleteInput

type NewsMassDeleteInput struct {
	IDs []int `json:"ids"`
}

type NewsMassUpdateInput

type NewsMassUpdateInput struct {
	IDs     []int   `json:"ids"`
	Content *string `json:"content"`
}

type NewsService

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

func NewNewsService

func NewNewsService(
	newsRepository repository.INewsRepository,
) NewsService

func (NewsService) Create

func (s NewsService) Create(ctx context.Context, input NewsCreateInput) (*model.News, error)

func (NewsService) Delete

func (s NewsService) Delete(ctx context.Context, id int) error

func (NewsService) Export

func (s NewsService) Export(ctx context.Context, data []byte) (*model3.Message, error)

func (NewsService) ExportList

func (s NewsService) ExportList(ctx context.Context) ([]model.News, error)

func (NewsService) GetById

func (s NewsService) GetById(ctx context.Context, id int) (*model.News, error)

func (NewsService) Import

func (s NewsService) Import(ctx context.Context, data []byte) (*model3.Message, error)

func (NewsService) List

func (s NewsService) List(ctx context.Context, m *model2.Meta[model.News]) error

func (NewsService) MassDelete

func (s NewsService) MassDelete(ctx context.Context, data []byte) (*model3.Message, error)

func (NewsService) MassUpdate

func (s NewsService) MassUpdate(ctx context.Context, data []byte) (*model3.Message, error)

func (NewsService) Trx

func (s NewsService) Trx(db *gorm.DB) INewsService

func (NewsService) Update

func (s NewsService) Update(ctx context.Context, id int, input NewsUpdateInput) error

type NewsUpdateInput

type NewsUpdateInput struct {
	Title   *string
	Content *string
}

type Services

type Services struct {
	NewsService INewsService
}

func NewServices

func NewServices(deps Deps) Services

Jump to

Keyboard shortcuts

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