repository

package
v0.0.0-...-f664ad0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDuplicateEmail 表示邮箱重复错误
	ErrDuplicateEmail = dao.ErrDuplicateEmail
	// ErrUserNotFound 表示用户未找到错误
	ErrUserNotFound = dao.ErrUserNotFound
)

Functions

This section is empty.

Types

type ActivityRepository

type ActivityRepository interface {
	GetRecentActivity(ctx context.Context) ([]domain.RecentActivity, error)
	SetRecentActivity(ctx context.Context, dr domain.RecentActivity) error
}

func NewActivityRepository

func NewActivityRepository(dao dao.ActivityDAO) ActivityRepository

type CachedInteractiveRepository

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

func (*CachedInteractiveRepository) BatchIncrReadCnt

func (c *CachedInteractiveRepository) BatchIncrReadCnt(ctx context.Context, biz []string, postIds []uint) error

func (*CachedInteractiveRepository) Collected

func (c *CachedInteractiveRepository) Collected(ctx context.Context, biz string, postId uint, uid int64) (bool, error)

func (*CachedInteractiveRepository) DecrCollectionItem

func (c *CachedInteractiveRepository) DecrCollectionItem(ctx context.Context, biz string, postId uint, cid int64, uid int64) error

func (*CachedInteractiveRepository) DecrLike

func (c *CachedInteractiveRepository) DecrLike(ctx context.Context, biz string, postId uint, uid int64) error

func (*CachedInteractiveRepository) Get

func (*CachedInteractiveRepository) GetById

func (c *CachedInteractiveRepository) GetById(ctx context.Context, biz string, postIds []uint) ([]domain.Interactive, error)

func (*CachedInteractiveRepository) IncrCollectionItem

func (c *CachedInteractiveRepository) IncrCollectionItem(ctx context.Context, biz string, postId uint, cid int64, uid int64) error

func (*CachedInteractiveRepository) IncrLike

func (c *CachedInteractiveRepository) IncrLike(ctx context.Context, biz string, postId uint, uid int64) error

func (*CachedInteractiveRepository) Liked

func (c *CachedInteractiveRepository) Liked(ctx context.Context, biz string, postId uint, uid int64) (bool, error)

type CheckRepository

type CheckRepository interface {
	Create(ctx context.Context, check domain.Check) (int64, error)                     // 创建审核记录
	UpdateStatus(ctx context.Context, check domain.Check) error                        // 更新审核状态
	FindAll(ctx context.Context, pagination domain.Pagination) ([]domain.Check, error) // 获取审核列表
	FindByID(ctx context.Context, checkID int64) (domain.Check, error)                 // 获取审核详情
	FindByPostId(ctx context.Context, postID uint) (domain.Check, error)               // 根据帖子ID获取审核信息
	GetCheckCount(ctx context.Context) (int64, error)                                  // 获取审核数量
}

func NewCheckRepository

func NewCheckRepository(dao dao.CheckDAO, cache cache.CheckCache, l *zap.Logger) CheckRepository

type CommentRepository

type CommentRepository interface {
	CreateComment(ctx context.Context, comment domain.Comment) error
	DeleteComment(ctx context.Context, commentId int64) error
	ListComments(ctx context.Context, postId, minID, limit int64) ([]domain.Comment, error)
	GetMoreCommentsReply(ctx context.Context, rootId, maxId, limit int64) ([]domain.Comment, error)
}

CommentRepository 评论仓库接口

func NewCommentRepository

func NewCommentRepository(dao dao.CommentDAO) CommentRepository

NewCommentRepository 创建新的评论服务

type CronJobRepository

type CronJobRepository interface {
	Preempt(ctx context.Context) (domain.Job, error)
	Release(ctx context.Context, jobId int64) error
	UpdateTime(ctx context.Context, id int64) error
	UpdateNextTime(ctx context.Context, id int64, nextTime time.Time) error
}

CronJobRepository 定义了定时任务仓库接口

func NewCronJobRepository

func NewCronJobRepository(dao dao.JobDAO) CronJobRepository

NewCronJobRepository 创建并初始化 cronJobRepository 实例

type EmailRepository

type EmailRepository interface {
	SendCode(ctx context.Context, email string) error
	CheckCode(ctx context.Context, email, vCode string) (bool, error)
}

func NewEmailRepository

func NewEmailRepository(cache cache.EmailCache, l *zap.Logger) EmailRepository

NewEmailRepository 创建并返回一个新的 smsRepository 实例

type HistoryRepository

type HistoryRepository interface {
	GetHistory(ctx context.Context, pagination domain.Pagination) ([]domain.History, error)
	SetHistory(ctx context.Context, post []domain.Post) error
	DeleteOneHistory(ctx context.Context, postId uint, uid int64) error
	DeleteAllHistory(ctx context.Context, uid int64) error
}

func NewHistoryRepository

func NewHistoryRepository(l *zap.Logger, cache cache.HistoryCache) HistoryRepository

type InteractiveRepository

type InteractiveRepository interface {
	// BatchIncrReadCnt biz 和 bizId 长度必须一致
	BatchIncrReadCnt(ctx context.Context, biz []string, postIds []uint) error                    // 批量更新阅读计数(与kafka配合使用)
	IncrLike(ctx context.Context, biz string, postId uint, uid int64) error                      // 增加阅读计数
	DecrLike(ctx context.Context, biz string, postId uint, uid int64) error                      // 减少阅读计数
	IncrCollectionItem(ctx context.Context, biz string, postId uint, cid int64, uid int64) error // 收藏
	DecrCollectionItem(ctx context.Context, biz string, postId uint, cid int64, uid int64) error // 取消收藏
	Get(ctx context.Context, biz string, postId uint) (domain.Interactive, error)                // 获取互动信息
	Liked(ctx context.Context, biz string, postId uint, uid int64) (bool, error)                 // 检查是否已点赞
	Collected(ctx context.Context, biz string, postId uint, uid int64) (bool, error)             // 检查是否被收藏
	GetById(ctx context.Context, biz string, postIds []uint) ([]domain.Interactive, error)       // 批量获取互动信息
}

type LotteryDrawRepository

type LotteryDrawRepository interface {
	// 抽奖活动相关方法
	ListLotteryDraws(ctx context.Context, status string, pagination domain.Pagination) ([]domain.LotteryDraw, error)
	CreateLotteryDraw(ctx context.Context, draw domain.LotteryDraw) error
	GetLotteryDrawByID(ctx context.Context, id int) (domain.LotteryDraw, error)
	ExistsLotteryDrawByName(ctx context.Context, name string) (bool, error)
	HasUserParticipatedInLottery(ctx context.Context, id int, userID int64) (bool, error)
	AddLotteryParticipant(ctx context.Context, dp domain.Participant) error

	// 秒杀活动相关方法
	ListSecondKillEvents(ctx context.Context, status string, pagination domain.Pagination) ([]domain.SecondKillEvent, error)
	CreateSecondKillEvent(ctx context.Context, input domain.SecondKillEvent) error
	GetSecondKillEventByID(ctx context.Context, id int) (domain.SecondKillEvent, error)
	ExistsSecondKillEventByName(ctx context.Context, name string) (bool, error)
	HasUserParticipatedInSecondKill(ctx context.Context, id int, userID int64) (bool, error)
	AddSecondKillParticipant(ctx context.Context, dp domain.Participant) error

	// 活动状态管理方法
	ListPendingLotteryDraws(ctx context.Context, currentTime int64) ([]domain.LotteryDraw, error)
	UpdateLotteryDrawStatus(ctx context.Context, id int, status string) error
	ListPendingSecondKillEvents(ctx context.Context, currentTime int64) ([]domain.SecondKillEvent, error)
	UpdateSecondKillEventStatus(ctx context.Context, id int, status string) error
	ListActiveLotteryDraws(ctx context.Context, currentTime int64) ([]domain.LotteryDraw, error)
	ListActiveSecondKillEvents(ctx context.Context, currentTime int64) ([]domain.SecondKillEvent, error)
}

func NewLotteryDrawRepository

func NewLotteryDrawRepository(dao dao.LotteryDrawDAO, logger *zap.Logger) LotteryDrawRepository

type PermissionRepository

type PermissionRepository interface {
	GetPermissions(ctx context.Context) ([]domain.Permission, error)                         // 获取权限列表
	AssignPermission(ctx context.Context, userName string, path string, method string) error // 分配权限
	AssignRoleToUser(ctx context.Context, userName, roleName string) error
	RemovePermission(ctx context.Context, userName string, path string, method string) error // 移除权限
	RemoveRoleFromUser(ctx context.Context, userName, roleName string) error
}

PermissionRepository 定义了权限仓库接口

func NewPermissionRepository

func NewPermissionRepository(l *zap.Logger, dao dao.PermissionDAO) PermissionRepository

NewPermissionRepository 创建一个新的 PermissionRepository

type PlateRepository

type PlateRepository interface {
	CreatePlate(ctx context.Context, plate domain.Plate) error
	ListPlate(ctx context.Context, pagination domain.Pagination) ([]domain.Plate, error)
	UpdatePlate(ctx context.Context, plate domain.Plate) error
	DeletePlate(ctx context.Context, plateId int64, uid int64) error
}

func NewPlateRepository

func NewPlateRepository(l *zap.Logger, dao dao.PlateDAO) PlateRepository

type PostRepository

type PostRepository interface {
	Create(ctx context.Context, post domain.Post) (uint, error)
	Update(ctx context.Context, post domain.Post) error
	UpdateStatus(ctx context.Context, post domain.Post) error
	GetPostById(ctx context.Context, postId uint, uid int64) (domain.Post, error)
	GetPublishedPostById(ctx context.Context, postId uint) (domain.Post, error)
	ListPublishedPosts(ctx context.Context, pagination domain.Pagination) ([]domain.Post, error)
	ListPosts(ctx context.Context, pagination domain.Pagination) ([]domain.Post, error)
	Delete(ctx context.Context, post domain.Post) error
	ListAllPost(ctx context.Context, pagination domain.Pagination) ([]domain.Post, error)
	GetPost(ctx context.Context, postId uint) (domain.Post, error)
	GetPostCount(ctx context.Context) (int64, error)
}

func NewPostRepository

func NewPostRepository(dao dao.PostDAO, l *zap.Logger, cb *bloom.CacheBloom, cl *local.CacheManager) PostRepository

type RankingRepository

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

func NewRankingCache

func NewRankingCache(redisCache cache.RankingRedisCache, localCache cache.RankingLocalCache, l *zap.Logger) RankingRepository

type RelationRepository

type RelationRepository interface {
	ListFollowerRelations(ctx context.Context, followerID int64, pagination domain.Pagination) ([]domain.Relation, error)
	ListFolloweeRelations(ctx context.Context, followeeID int64, pagination domain.Pagination) ([]domain.Relation, error)
	FollowUser(ctx context.Context, followerID, followeeID int64) error
	CancelFollowUser(ctx context.Context, followerID, followeeID int64) error
	GetFolloweeCount(ctx context.Context, userID int64) (int64, error)
	GetFollowerCount(ctx context.Context, userID int64) (int64, error)
}

RelationRepository 定义了关注关系的存储库接口

func NewRelationRepository

func NewRelationRepository(dao dao.RelationDAO, cache cache.RelationCache, logger *zap.Logger) RelationRepository

type SearchRepository

type SearchRepository interface {
	SearchPosts(ctx context.Context, keywords []string) ([]domain.PostSearch, error) // 搜索文章
	SearchUsers(ctx context.Context, keywords []string) ([]domain.UserSearch, error) // 搜索用户
	InputUser(ctx context.Context, user domain.UserSearch) error                     // 处理输入用户
	InputPost(ctx context.Context, post domain.PostSearch) error                     // 处理输入文章
	DeleteUserIndex(ctx context.Context, userId int64) error                         // 删除用户索引
	DeletePostIndex(ctx context.Context, postId uint) error                          // 删除文章索引
}

func NewSearchRepository

func NewSearchRepository(dao dao.SearchDAO) SearchRepository

type SmsRepository

type SmsRepository interface {
	CheckCode(ctx context.Context, smsID, number, vCode string) (bool, error)
	AddUserOperationLog(ctx context.Context, log dao.VCodeSmsLog) error
	SetNX(ctx context.Context, number string, value interface{}, expiration time.Duration) (*redis.BoolCmd, error)
	StoreVCode(ctx context.Context, smsID, number string, vCode string) error
	Exist(ctx context.Context, number string) bool
	Count(ctx context.Context, number string) int
	IncrCnt(ctx context.Context, number string) error
	ReleaseLock(ctx context.Context, number string) error
	SendCode(ctx context.Context, number string) error
}

SmsRepository 接口定义了异步 SMS 记录操作的相关方法

func NewSmsRepository

func NewSmsRepository(dao dao.SmsDAO, cache cache.SMSCache, l *zap.Logger, client *sms.TencentSms) SmsRepository

NewSmsRepository 创建并返回一个新的 smsRepository 实例

type UserRepository

type UserRepository interface {
	// CreateUser 创建用户
	CreateUser(ctx context.Context, u domain.User) error
	// FindByID 根据用户ID查找用户
	FindByID(ctx context.Context, id int64) (domain.User, error)
	// FindByPhone 根据手机号查找用户
	FindByPhone(ctx context.Context, phone string) (domain.User, error)
	// FindByEmail 根据邮箱查找用户
	FindByEmail(ctx context.Context, email string) (domain.User, error)
	// ChangePassword 修改密码
	ChangePassword(ctx context.Context, email string, newPassword string) error
	// DeleteUser 删除用户
	DeleteUser(ctx context.Context, email string, uid int64) error
	// UpdateProfile 更新用户资料
	UpdateProfile(ctx context.Context, profile domain.Profile) error
	// GetProfile 根据用户ID获取用户资料
	GetProfile(ctx context.Context, UserId int64) (domain.Profile, error)
	// ListUser 获取用户列表
	ListUser(ctx context.Context, pagination domain.Pagination) ([]domain.UserWithProfileAndRule, error)
	// GetUserCount 获取用户总数
	GetUserCount(ctx context.Context) (int64, error)
}

UserRepository 定义用户仓库接口

func NewUserRepository

func NewUserRepository(dao dao.UserDAO, cache cache.UserCache, l *zap.Logger) UserRepository

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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