service

package
v0.0.0-...-7efebb4 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateEmail        = repository.ErrUserDuplicate
	ErrInvalidUserOrPassword = errors.New("用户不存在或者密码不对")
)

定义业务处理的异常

View Source
var (
	ErrTooManyCodeSend = cache.ErrNextCodeTooSoon
)

Functions

This section is empty.

Types

type ArticleService

type ArticleService interface {
	GetById(context.Context, int64) (domain.Article, error)
	// Save upsert语义
	Save(context.Context, domain.Article) (int64, error)
	List(ctx context.Context, authorId int64, limit int, offset int) ([]domain.Article, error)
	// 操作的表不一样
	Publish(context.Context, domain.Article) (int64, error)
	WithDraw(ctx context.Context, userId int64, artId int64) error
	GetPubById(ctx context.Context, artId int64) (domain.PublishedArticle, error)
	ListPub(ctx context.Context, start time.Time, offset int, batchSize int) ([]domain.PublishedArticle, error)
}

func NewArticleService

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

type BatchRankingService

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

func NewBatchRankingService

func NewBatchRankingService(n int, batchSize int, artSvc ArticleService, usrActSvc UserActivityService, scoreFn func(readCnt int64, utime time.Time) float64, repo repository.RankingRepository) *BatchRankingService

func (*BatchRankingService) RankTopN

func (b *BatchRankingService) RankTopN(ctx context.Context) error

func (*BatchRankingService) TopN

type CodeService

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

func NewSMSCodeService

func NewSMSCodeService(repo *repository.CodeRepository, decorator *prometheus.Decorator) CodeService

type PriorityQueue

type PriorityQueue []*Score

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

type RankingService

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

type SMSCodeService

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

func (*SMSCodeService) Send

func (c *SMSCodeService) Send(ctx context.Context, biz string, phone string) error

func (*SMSCodeService) Verify

func (c *SMSCodeService) Verify(ctx context.Context, biz string, phone string, code string) (bool, error)

type Score

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

type UserActivityService

type UserActivityService interface {
	IncrRead(ctx context.Context, biz string, bizId int64) error
	GetReadByIds(ctx context.Context, biz string, ids []int64) ([]domain.UserActivity, error)
}

type UserService

type UserService interface {
	FindById(ctx context.Context, uid int64) (domain.User, error)
	Signup(context.Context, domain.User) error
	FindOrCreate(ctx context.Context, phone string) (domain.User, error)
	Login(ctx context.Context, email, password string) (domain.User, error)
	UpdateNonPII(ctx context.Context, user domain.User) error
}

UserService 用户相关服务

func NewUserService

func NewUserService(repo repository.UserRepository) UserService

Directories

Path Synopsis
Code generated by MockGen.
Code generated by MockGen.
sms

Jump to

Keyboard shortcuts

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