repository

package
v0.0.0-...-d13da26 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCodeSendTooMany        = cache.ErrCodeSendTooMany
	ErrCodeVerifyTooManyTimes = cache.ErrCodeVerifyTooManyTimes
)
View Source
var (
	ErrUserDuplicate = dao.ErrUserDuplicate
	ErrUserNotFound  = dao.ErrUserNotFound
)

Functions

This section is empty.

Types

type CachedCodeRepository

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

func (*CachedCodeRepository) Store

func (repo *CachedCodeRepository) Store(ctx context.Context, biz string,
	phone string, code string) error

func (*CachedCodeRepository) Verify

func (repo *CachedCodeRepository) Verify(ctx context.Context, biz, phone, inputCode string) (bool, error)

type CachedRankingRepository

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

func (*CachedRankingRepository) GetTopN

func (*CachedRankingRepository) ReplaceTopN

func (c *CachedRankingRepository) ReplaceTopN(ctx context.Context, arts []domain.Article) error

type CachedReadCntRepository

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

func (*CachedReadCntRepository) AddCollectionItem

func (c *CachedReadCntRepository) AddCollectionItem(ctx context.Context,
	biz string, bizId, cid, uid int64) error

func (*CachedReadCntRepository) AddRecord

func (c *CachedReadCntRepository) AddRecord(ctx context.Context, aid int64, uid int64) error

func (*CachedReadCntRepository) BatchIncrReadCnt

func (c *CachedReadCntRepository) BatchIncrReadCnt(ctx context.Context,
	bizs []string, bizId []int64) error

BatchIncrReadCnt bizs 和 ids 的长度必须相等

func (*CachedReadCntRepository) Collected

func (c *CachedReadCntRepository) Collected(ctx context.Context, biz string, id int64, uid int64) (bool, error)

func (*CachedReadCntRepository) DecrLike

func (c *CachedReadCntRepository) DecrLike(ctx context.Context,
	biz string, bizId int64, uid int64) error

func (*CachedReadCntRepository) Get

func (*CachedReadCntRepository) GetCollection

func (c *CachedReadCntRepository) GetCollection() (domain.Collection, error)

func (*CachedReadCntRepository) IncrLike

func (c *CachedReadCntRepository) IncrLike(ctx context.Context,
	biz string, bizId int64, uid int64) error

func (*CachedReadCntRepository) IncrReadCnt

func (c *CachedReadCntRepository) IncrReadCnt(ctx context.Context,
	biz string, bizId int64) error

func (*CachedReadCntRepository) Liked

func (c *CachedReadCntRepository) Liked(ctx context.Context, biz string, id int64, uid int64) (bool, error)

func (*CachedReadCntRepository) UpdateCnt

func (c *CachedReadCntRepository) UpdateCnt(intr *dao.Interactive)

UpdateCnt 这不是好的实践

func (*CachedReadCntRepository) UpdateCntV1

func (c *CachedReadCntRepository) UpdateCntV1(intr dao.Interactive) dao.Interactive

UpdateCntV1 凑合的实践

type CachedUserRepository

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

func (*CachedUserRepository) Create

func (*CachedUserRepository) FindByEmail

func (r *CachedUserRepository) FindByEmail(ctx context.Context, email string) (domain.User, error)

func (*CachedUserRepository) FindById

func (r *CachedUserRepository) FindById(ctx context.Context, id int64) (domain.User, error)

func (*CachedUserRepository) FindByPhone

func (r *CachedUserRepository) FindByPhone(ctx context.Context, phone string) (domain.User, error)

func (*CachedUserRepository) FindByWechat

func (r *CachedUserRepository) FindByWechat(ctx context.Context, openID string) (domain.User, error)

type CodeRepository

type CodeRepository interface {
	Store(ctx context.Context, biz string,
		phone string, code string) error
	Verify(ctx context.Context, biz, phone, inputCode string) (bool, error)
}

func NewCodeRepository

func NewCodeRepository(c cache.CodeCache) CodeRepository

type InteractiveRepository

type InteractiveRepository interface {
	IncrReadCnt(ctx context.Context,
		biz string, bizId int64) error
	BatchIncrReadCnt(ctx context.Context,
		biz []string, bizId []int64) error
	IncrLike(ctx context.Context, biz string, bizId, uid int64) error
	DecrLike(ctx context.Context, biz string, bizId, uid int64) error
	AddCollectionItem(ctx context.Context, biz string, bizId, cid int64, uid int64) error
	Get(ctx context.Context, biz string, bizId int64) (domain.Interactive, error)
	Liked(ctx context.Context, biz string, id int64, uid int64) (bool, error)
	Collected(ctx context.Context, biz string, id int64, uid int64) (bool, error)
	AddRecord(ctx context.Context, aid int64, uid int64) error
}

type JobRepository

type JobRepository interface {
	Preempt(ctx context.Context, refreshInterval time.Duration) (domain.Job, error)
	Release(ctx context.Context, id int64) error
	UpdateUtime(ctx context.Context, id int64) error
	UpdateNextTime(ctx context.Context, id int64, next time.Time) error
	Stop(ctx context.Context, id int64) error
}

type PreemptCronJobRepository

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

func (*PreemptCronJobRepository) Preempt

func (p *PreemptCronJobRepository) Preempt(ctx context.Context, refreshInterval time.Duration) (domain.Job, error)

func (*PreemptCronJobRepository) Release

func (p *PreemptCronJobRepository) Release(ctx context.Context, id int64) error

func (*PreemptCronJobRepository) Stop

func (*PreemptCronJobRepository) UpdateNextTime

func (p *PreemptCronJobRepository) UpdateNextTime(ctx context.Context, id int64, next time.Time) error

func (*PreemptCronJobRepository) UpdateUtime

func (p *PreemptCronJobRepository) UpdateUtime(ctx context.Context, id int64) error

type RankingRepository

type RankingRepository interface {
	ReplaceTopN(ctx context.Context, arts []domain.Article) error
	GetTopN(ctx context.Context) ([]domain.Article, error)
}

func NewCachedRankingRepository

func NewCachedRankingRepository(
	redis *cache.RankingRedisCache,
	local *cache.RankingLocalCache,
) RankingRepository

type UserRepository

type UserRepository interface {
	FindByEmail(ctx context.Context, email string) (domain.User, error)
	FindByPhone(ctx context.Context, phone string) (domain.User, error)
	Create(ctx context.Context, u domain.User) error
	FindById(ctx context.Context, id int64) (domain.User, error)
	FindByWechat(ctx context.Context, openID string) (domain.User, error)
}

UserRepository 是核心,它有不同实现。 但是 Factory 本身如果只是初始化一下,那么它不是你的核心

func NewUserRepository

func NewUserRepository(dao dao.UserDAO, c cache.UserCache) UserRepository

Directories

Path Synopsis
mocks
Package artrepomocks is a generated GoMock package.
Package artrepomocks is a generated GoMock package.
mocks
Package cachemocks is a generated GoMock package.
Package cachemocks is a generated GoMock package.
redismocks
Package redismocks is a generated GoMock package.
Package redismocks is a generated GoMock package.
dao
mocks
Package daomocks is a generated GoMock package.
Package daomocks is a generated GoMock package.
Package repomocks is a generated GoMock package.
Package repomocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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