repository

package
v0.0.0-...-6ea431b Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

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 string, phone string, inputCode string) (bool, error)

Verify 比较验证码。如果验证码相等,那么删除;

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) 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)

type CachedUserRepository

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

CachedUserRepository 使用了缓存的 repository 实现

func (*CachedUserRepository) Create

func (ur *CachedUserRepository) Create(ctx context.Context, u domain.User) error

func (*CachedUserRepository) FindByEmail

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

func (*CachedUserRepository) FindById

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

func (*CachedUserRepository) FindByPhone

func (ur *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)

func (*CachedUserRepository) Update

func (ur *CachedUserRepository) Update(ctx context.Context, u domain.User) error

type CodeRepository

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

func NewCachedCodeRepository

func NewCachedCodeRepository(c cache.CodeCache) CodeRepository

type InteractiveRepository

type InteractiveRepository interface {
	IncrReadCnt(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)
}

type UserRepository

type UserRepository interface {
	Create(ctx context.Context, u domain.User) error
	// Update 更新数据,只有非 0 值才会更新
	Update(ctx context.Context, u domain.User) error
	FindByPhone(ctx context.Context, phone string) (domain.User, error)
	FindByEmail(ctx context.Context, email string) (domain.User, error)
	FindById(ctx context.Context, id int64) (domain.User, error)
	FindByWechat(ctx context.Context, openID string) (domain.User, error)
}

func NewCachedUserRepository

func NewCachedUserRepository(d dao.UserDAO, c cache.UserCache) UserRepository

NewCachedUserRepository 也说明了 CachedUserRepository 的特性 会从缓存和数据库中去尝试获得

Directories

Path Synopsis
mocks
Code generated by MockGen.
Code generated by MockGen.
mocks
Code generated by MockGen.
Code generated by MockGen.
redismocks
Code generated by MockGen.
Code generated by MockGen.
dao
article/mocks
Code generated by MockGen.
Code generated by MockGen.
mocks
Code generated by MockGen.
Code generated by MockGen.
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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