repository

package
v0.0.0-...-1b0a6d5 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDuplicateUsername 表示用户名重复错误
	ErrDuplicateUsername = dao.ErrDuplicateUsername
)

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 ApiRepository

type ApiRepository interface {
	CreateApi(ctx context.Context, api *domain.Api) error
	GetApiById(ctx context.Context, id int) (*domain.Api, error)
	UpdateApi(ctx context.Context, api *domain.Api) error
	DeleteApi(ctx context.Context, id int) error
	ListApis(ctx context.Context, page, pageSize int) ([]*domain.Api, int, error)
}

func NewApiRepository

func NewApiRepository(l *zap.Logger, dao dao.ApiDAO) ApiRepository

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 MenuRepository interface {
	CreateMenu(ctx context.Context, menu *domain.Menu) error
	GetMenuById(ctx context.Context, id int) (*domain.Menu, error)
	UpdateMenu(ctx context.Context, menu *domain.Menu) error
	DeleteMenu(ctx context.Context, id int) error
	ListMenus(ctx context.Context, page, pageSize int) ([]*domain.Menu, int, error)
	GetMenuTree(ctx context.Context) ([]*domain.Menu, error)
}

func NewMenuRepository

func NewMenuRepository(l *zap.Logger, dao dao.MenuDAO) MenuRepository

type PermissionRepository

type PermissionRepository interface {
	AssignRole(ctx context.Context, roleId int, menuIds []int, apiIds []int) error
	AssignRoleToUser(ctx context.Context, userId int, roleIds []int, menuIds []int, apiIds []int) error
	AssignRoleToUsers(ctx context.Context, userIds []int, roleIds []int, menuIds []int, apiIds []int) error
	RemoveUserPermissions(ctx context.Context, userId int) error
	RemoveRolePermissions(ctx context.Context, roleId int) error
	RemoveUsersPermissions(ctx context.Context, userIds []int) error
}

func NewPermissionRepository

func NewPermissionRepository(l *zap.Logger, dao dao.PermissionDAO) 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 RoleRepository

type RoleRepository interface {
	CreateRole(ctx context.Context, role *domain.Role, menuIds []int, apiIds []int) error
	GetRoleById(ctx context.Context, id int) (*domain.Role, error)
	UpdateRole(ctx context.Context, role *domain.Role) error
	DeleteRole(ctx context.Context, id int) error
	ListRoles(ctx context.Context, page, pageSize int) ([]*domain.Role, int, error)
	GetUserRole(ctx context.Context, userId int) (*domain.Role, error)
	GetRole(ctx context.Context, roleId int) (*domain.Role, error)
}

func NewRoleRepository

func NewRoleRepository(l *zap.Logger, dao dao.RoleDAO) RoleRepository

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(ctx context.Context, u domain.User) error
	FindByID(ctx context.Context, id int64) (domain.User, error)
	FindByPhone(ctx context.Context, phone string) (domain.User, error)
	FindByUsername(ctx context.Context, username string) (domain.User, error)
	ChangePassword(ctx context.Context, username string, newPassword string) error
	DeleteUser(ctx context.Context, username string, uid int64) error
	UpdateProfile(ctx context.Context, profile domain.Profile) error
	GetProfile(ctx context.Context, UserID int64) (domain.Profile, error)
	ListUser(ctx context.Context, pagination domain.Pagination) ([]domain.UserWithProfile, error)
}

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