repository

package
v0.0.0-...-a80dff1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: MIT Imports: 22 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 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)                                  // 获取审核数量
	WithTx(ctx context.Context, fn func(txCtx context.Context) error) error            // 事务
}

func NewCheckRepository

func NewCheckRepository(dao dao.CheckDAO, 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(ctx context.Context, postIds []uint) error
	IncrReadCnt(ctx context.Context, postId uint) error
	IncrLike(ctx context.Context, postId uint, uid int64) error
	DecrLike(ctx context.Context, postId uint, uid int64) error
	IncrCollectionItem(ctx context.Context, postId uint, uid int64) error
	DecrCollectionItem(ctx context.Context, postId uint, uid int64) error
	Get(ctx context.Context, postId uint) (domain.Interactive, error)
	Liked(ctx context.Context, postId uint, uid int64) (bool, error)
	Collected(ctx context.Context, postId uint, uid int64) (bool, error)
	GetById(ctx context.Context, postIds []uint) ([]domain.Interactive, error)
}

func NewInteractiveRepository

func NewInteractiveRepository(dao dao.InteractiveDAO, l *zap.Logger) InteractiveRepository

type InteractiveRepositoryImpl

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

func (*InteractiveRepositoryImpl) BatchIncrReadCnt

func (i *InteractiveRepositoryImpl) BatchIncrReadCnt(ctx context.Context, postIds []uint) error

BatchIncrReadCnt 批量增加阅读计数

func (*InteractiveRepositoryImpl) Collected

func (i *InteractiveRepositoryImpl) Collected(ctx context.Context, postId uint, uid int64) (bool, error)

Collected 检查是否已收藏

func (*InteractiveRepositoryImpl) DecrCollectionItem

func (i *InteractiveRepositoryImpl) DecrCollectionItem(ctx context.Context, postId uint, uid int64) error

DecrCollectionItem 减少收藏计数

func (*InteractiveRepositoryImpl) DecrLike

func (i *InteractiveRepositoryImpl) DecrLike(ctx context.Context, postId uint, uid int64) error

DecrLike 减少点赞计数

func (*InteractiveRepositoryImpl) Get

Get 获取互动信息

func (*InteractiveRepositoryImpl) GetById

func (i *InteractiveRepositoryImpl) GetById(ctx context.Context, postIds []uint) ([]domain.Interactive, error)

GetById 批量获取互动信息

func (*InteractiveRepositoryImpl) IncrCollectionItem

func (i *InteractiveRepositoryImpl) IncrCollectionItem(ctx context.Context, postId uint, uid int64) error

IncrCollectionItem 增加收藏计数

func (*InteractiveRepositoryImpl) IncrLike

func (i *InteractiveRepositoryImpl) IncrLike(ctx context.Context, postId uint, uid int64) error

IncrLike 增加点赞计数

func (*InteractiveRepositoryImpl) IncrReadCnt

func (i *InteractiveRepositoryImpl) IncrReadCnt(ctx context.Context, postId uint) error

IncrReadCnt implements InteractiveRepository.

func (*InteractiveRepositoryImpl) Liked

func (i *InteractiveRepositoryImpl) Liked(ctx context.Context, postId uint, uid int64) (bool, error)

Liked 检查是否已点赞

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, postId uint, uid int64, status uint8) error
	GetPostById(ctx context.Context, postId uint, uid int64) (domain.Post, error)
	GetPublishPostById(ctx context.Context, postId uint) (domain.Post, error)
	ListPublishPosts(ctx context.Context, pagination domain.Pagination) ([]domain.Post, error)
	ListPosts(ctx context.Context, pagination domain.Pagination) ([]domain.Post, error)
	Delete(ctx context.Context, postId uint, uid int64) error
	GetPost(ctx context.Context, postId uint) (domain.Post, error)
	ListAllPosts(ctx context.Context, pagination domain.Pagination) ([]domain.Post, error)
}

func NewPostRepository

func NewPostRepository(dao dao.PostDAO, l *zap.Logger, cache cache.PostCache, asynqClient *asynq.Client) 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) // 搜索用户
	IsExistPost(ctx context.Context, postId uint) (bool, error)
	IsExistUser(ctx context.Context, userId int64) (bool, error)
	InputUser(ctx context.Context, user domain.UserSearch) error // 处理输入用户
	InputPost(ctx context.Context, post domain.PostSearch) error
	BulkInputLogs(ctx context.Context, event []domain.ReadEvent) 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)
	UpdateProfileAdmin(ctx context.Context, profile domain.Profile) 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