service

package
v0.0.0-...-24b49fa Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Domain service

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrArticleNotFound = repository.ErrArticleNotFound
	ErrPublish         = errors.New("still failed to publish article after retries")
)
View Source
var (
	ErrCodeSendTooMany   = repository.ErrCodeSendTooMany
	ErrCodeVerifyTooMany = repository.ErrCodeVerifyTooMany
)
View Source
var (
	ErrDuplicatedUser        = repository.ErrDuplicatedUser
	ErrInvalidUserOrPassword = errors.New("wrong email or password")
	ErrInvalidUserID         = errors.New("unknown userID")
)

Functions

func NewArticleServiceV1

func NewArticleServiceV1(
	l logger.Logger,
	readerRepo repository.ArticleReaderRepository,
	authorRepo repository.ArticleAuthorRepository,
) *articleService

Types

type ArticleService

type ArticleService interface {
	Save(ctx context.Context, article domain.Article) (int64, error)
	Publish(ctx context.Context, article domain.Article) (int64, error)
	Withdraw(ctx context.Context, userID int64, articleID int64) error
	GetByAuthor(ctx context.Context, uid int64, offset int, limit int) ([]domain.Article, error)
	GetByID(ctx context.Context, id int64) (domain.Article, error)
	GetPubByID(ctx context.Context, id int64, uid int64) (domain.Article, error)
	BatchGetPubByIDs(ctx context.Context, ids []int64) ([]domain.Article, error)
	ListPub(ctx context.Context, start time.Time, offset, limit int) ([]domain.Article, error)
}

func NewArticleService

func NewArticleService(
	repo repository.ArticleRepository,
	producer article.Producer,
) ArticleService

type BatchRankingService

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

func (*BatchRankingService) GetTopN

func (b *BatchRankingService) GetTopN(ctx context.Context) ([]domain.Article, error)

GetTopN implements RankingService.

func (*BatchRankingService) TopN

TopN implements RankingService.

type CodeService

type CodeService interface {
	Send(ctx context.Context, biz string, phone string, tpl *template.Template) error
	Verify(ctx context.Context, biz string, phone string, inputCode string) (bool, error)
}

func NewCodeService

func NewCodeService(repo repository.CodeRepository, sms sms.Service) CodeService

type JobService

type JobService interface {
	Preempt(ctx context.Context) (domain.Job, error)
	ResetNextTime(ctx context.Context, job domain.Job) error
}

func NewCronJobService

func NewCronJobService(
	l logger.Logger,
	repo repository.JobRepository,
) JobService

type RankingService

type RankingService interface {
	TopN(ctx context.Context) error
	GetTopN(ctx context.Context) ([]domain.Article, error)
}

type UserService

type UserService interface {
	SignUp(ctx context.Context, u domain.User) (domain.User, error)
	Login(ctx context.Context, email string, password string) (domain.User, error)
	EditProfile(ctx context.Context, user *domain.User) error
	GetProfile(ctx context.Context, userID int64) (domain.User, error)
	FindOrCreate(ctx context.Context, phone string) (domain.User, error)
	FindOrCreateByGitea(ctx context.Context, info domain.GiteaInfo) (domain.User, error)
}

func NewUserService

func NewUserService(repo repository.UserRepository) UserService

Directories

Path Synopsis
Package svcmocks is a generated GoMock package.
Package svcmocks is a generated GoMock package.
oauth2
sms
mocks
Package smsmocks is a generated GoMock package.
Package smsmocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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