service

package
v0.0.0-...-0ca6d7b Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: MIT Imports: 13 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)
}

func NewArticleService

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

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 InteractiveService

type InteractiveService interface {
	IncrReadCnt(ctx context.Context, biz string, bizID int64) error
	Like(ctx context.Context, biz string, id int64, uid int64) error
	CancelLike(ctx context.Context, biz string, id int64, uid int64) error
	Collect(ctx context.Context, biz string, id int64, cid int64, uid int64) error
	CancelCollect(ctx context.Context, biz string, id int64, cid int64, uid int64) error
	Get(ctx context.Context, biz string, id int64, uid int64) (domain.Interactive, 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)
}

NOTE: 1. For test purpose 2. UserServiceV1 V2, etc 3. UserServiceVIP ...

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