Documentation ¶
Index ¶
- Variables
- type CommentService
- func (c *CommentService) AddComment(commentModel *system.Comment) error
- func (c *CommentService) AddCommentRedis(commentModel *system.Comment) error
- func (c *CommentService) DeleteComment(commentID, videoID uint64) error
- func (c *CommentService) DeleteCommentRedis(commentID, videoID uint64) error
- func (c *CommentService) GetCommentListByCommentIDListRedis(commentModelList *[]system.Comment, commentIDList []uint64) error
- func (c *CommentService) GetCommentListByCommentIDListSql(commentList *[]system.Comment, commentIDList []uint64) error
- func (c *CommentService) GetVideoCommentListByVideoIDSql(videoID uint64, commentList *[]system.Comment) error
- func (c *CommentService) GetVideoCommentListRedis(videoID uint64, commentModelList *[]system.Comment) error
- func (c *CommentService) SetCommentListRedis(commentList []system.Comment) error
- func (c *CommentService) SetVideoCommentEmpty(videoID uint64) error
- func (c *CommentService) SetVideoCommentIDListRedis(videoID uint64, listZ ...*redis.Z) error
- type FavoriteService
- func (f *FavoriteService) AddFavoriteAction(userID, videoID uint64) error
- func (f *FavoriteService) AddVideoFavoriteRedis(userID, videoID uint64)
- func (f *FavoriteService) CancelFavoriteAction(userID, videoID uint64) error
- func (f *FavoriteService) GetFavoriteStatusList(userID uint64, videoIDList []uint64) ([]bool, error)
- func (f *FavoriteService) GetFavoriteVideoIDListRedis(userID uint64, videoIDList *[]uint64) error
- func (f *FavoriteService) GetFavoriteVideoListByUserIDSql(userID uint64, videoList *[]system.Video) error
- func (f *FavoriteService) GetFavoriteVideoListRedis(userID uint64, videoList *[]system.Video) error
- func (f *FavoriteService) GetVideoFavoriteStatusByUserIDRedis(userID, videoID uint64) (bool, error)
- func (f *FavoriteService) SetFavoriteVideoIDListRedis(userID uint64, listZ ...*redis.Z) error
- func (f *FavoriteService) SetUserFavoriteEmpty(userID uint64) error
- func (f *FavoriteService) SetVideoCommentEmpty(videoID uint64) error
- func (f *FavoriteService) SubVideoFavoriteRedis(userID, videoID uint64)
- type FeedService
- func (f *FeedService) GetAuthorIDByVideoID(videoID uint64) (authorID uint64, err error)
- func (f *FeedService) GetFeedVideoListRedis(videoList *[]system.Video, authorList *[]system.User, latestTime string) error
- func (f *FeedService) GetStartTime(startTime string) string
- func (f *FeedService) GetVideoListByVideoIDListRedis(videoList *[]system.Video, videoIDList []uint64) error
- func (f *FeedService) GetVideoListByVideoIDListSql(videoList *[]system.Video, videoIDList []uint64) error
- func (f *FeedService) SetFeedCache() error
- func (f *FeedService) SetVideoListRedis(videoList []system.Video) error
- type PublishService
- func (p *PublishService) CheckVideo(data *multipart.FileHeader, title string) (*comRes.Response, error)
- func (p *PublishService) CreateVideo(video *system.Video) error
- func (p *PublishService) GetPublishedVideoListRedis(userID uint64, videoList *[]system.Video) error
- func (p *PublishService) GetVideoListByUserIDSql(userID uint64, videoList *[]system.Video) error
- func (p *PublishService) LocalSave(c *gin.Context, data *multipart.FileHeader, userId uint64) (string, string, error)
- func (p *PublishService) OssUpload(data *multipart.FileHeader, video, image string) (string, string, error)
- func (p *PublishService) SetPublishedVideoIDListRedis(userID uint64, listZ ...*redis.Z) error
- func (p *PublishService) SetUserPublishEmpty(userID uint64) error
- func (p *PublishService) SetVideoListRedis(videoList []system.Video) error
- type RelationService
- func (r *RelationService) AddRelationAction(fromUserID, toUserID uint64) error
- func (r *RelationService) AddUserFollowRedis(fromUserID, toUserID uint64)
- func (r *RelationService) CancelRelationAction(fromUserID, toUserID uint64) error
- func (r *RelationService) GetFollowStatus(fromUserID, toUserID uint64) (bool, error)
- func (r *RelationService) GetFollowStatusList(userID uint64, authorIDList []uint64) ([]bool, error)
- func (r *RelationService) GetFollowUserIDListRedis(userID uint64, followUserIDList *[]uint64) error
- func (r *RelationService) GetFollowUserListRedis(userID uint64, followUserList *[]system.User) error
- func (r *RelationService) GetFollowUserListSql(fromUserID uint64, followUserList *[]system.User) error
- func (r *RelationService) GetFollowerUserListRedis(userID uint64, followerUserList *[]system.User) error
- func (r *RelationService) GetFollowerUserListSql(toUserID uint64, followerUserList *[]system.User) error
- func (r *RelationService) GetUserFollowStatusByUserIDRedis(fromUserID, toUserID uint64) (bool, error)
- func (r *RelationService) SetFollowUserIDListRedis(userID uint64, listZ ...*redis.Z) error
- func (r *RelationService) SetFollowerUserIDListRedis(userID uint64, listZ ...*redis.Z) error
- func (r *RelationService) SetUserFollowEmpty(userID uint64) error
- func (r *RelationService) SetUserFollowerEmpty(userID uint64) error
- func (r *RelationService) SubUserFollowRedis(fromUserID, toUserID uint64)
- type ServiceGroup
- type UserService
- func (u *UserService) GetUserInfoByUserIDListSql(userID uint64, userInfo *system.User) error
- func (u *UserService) GetUserInfoByUserIDRedis(userID uint64, userInfo *system.User) error
- func (u *UserService) GetUserListByIDListRedis(authorList *[]system.User, authorIDList []uint64) error
- func (u *UserService) GetUserListByUserIDListSql(userList *[]system.User, userIDList []uint64) error
- func (u *UserService) IsLegal(username, password string) error
- func (u *UserService) Login(username, password string) (*system.User, error)
- func (u *UserService) Register(username, password string) (*system.User, error)
- func (u *UserService) SetUserInfoToRedis(user *system.User) error
- func (u *UserService) SetUserListToRedis(userList *[]system.User) error
Constants ¶
This section is empty.
Variables ¶
var ServiceGroupApp = new(ServiceGroup)
Functions ¶
This section is empty.
Types ¶
type CommentService ¶
type CommentService struct { }
func (*CommentService) AddComment ¶
func (c *CommentService) AddComment(commentModel *system.Comment) error
AddComment 添加评论,若redis添加缓存失败将回滚
func (*CommentService) AddCommentRedis ¶
func (c *CommentService) AddCommentRedis(commentModel *system.Comment) error
AddCommentRedis 添加评论的缓存操作
func (*CommentService) DeleteComment ¶
func (c *CommentService) DeleteComment(commentID, videoID uint64) error
DeleteComment 删除评论,若操作redis缓存失败将回滚
func (*CommentService) DeleteCommentRedis ¶
func (c *CommentService) DeleteCommentRedis(commentID, videoID uint64) error
DeleteCommentRedis 删除评论的缓存操作
func (*CommentService) GetCommentListByCommentIDListRedis ¶
func (c *CommentService) GetCommentListByCommentIDListRedis(commentModelList *[]system.Comment, commentIDList []uint64) error
GetCommentListByCommentIDListRedis 根据评论ID列表从缓存中查找评论信息
func (*CommentService) GetCommentListByCommentIDListSql ¶
func (c *CommentService) GetCommentListByCommentIDListSql(commentList *[]system.Comment, commentIDList []uint64) error
GetCommentListByCommentIDListSql 当缓存未命中时,根据评论ID列表从数据库查询数据,并写入缓存
func (*CommentService) GetVideoCommentListByVideoIDSql ¶
func (c *CommentService) GetVideoCommentListByVideoIDSql(videoID uint64, commentList *[]system.Comment) error
GetVideoCommentListByVideoIDSql 查询视频的评论列表
func (*CommentService) GetVideoCommentListRedis ¶
func (c *CommentService) GetVideoCommentListRedis(videoID uint64, commentModelList *[]system.Comment) error
GetVideoCommentListRedis 获取视频的评论列表
func (*CommentService) SetCommentListRedis ¶
func (c *CommentService) SetCommentListRedis(commentList []system.Comment) error
SetCommentListRedis 将评论信息列表批量写入缓存
func (*CommentService) SetVideoCommentEmpty ¶
func (c *CommentService) SetVideoCommentEmpty(videoID uint64) error
SetVideoCommentEmpty 设置视频评论列表为空的空值缓存处理
func (*CommentService) SetVideoCommentIDListRedis ¶
func (c *CommentService) SetVideoCommentIDListRedis(videoID uint64, listZ ...*redis.Z) error
SetVideoCommentIDListRedis 将视频的评论ID列表加入缓存
type FavoriteService ¶
type FavoriteService struct { }
func (*FavoriteService) AddFavoriteAction ¶
func (f *FavoriteService) AddFavoriteAction(userID, videoID uint64) error
AddFavoriteAction 点赞操作
func (*FavoriteService) AddVideoFavoriteRedis ¶
func (f *FavoriteService) AddVideoFavoriteRedis(userID, videoID uint64)
AddVideoFavoriteRedis 点赞成功后,如果缓存存在,更新视频被点赞数,用户点赞列表
func (*FavoriteService) CancelFavoriteAction ¶
func (f *FavoriteService) CancelFavoriteAction(userID, videoID uint64) error
CancelFavoriteAction 取消点赞
func (*FavoriteService) GetFavoriteStatusList ¶
func (f *FavoriteService) GetFavoriteStatusList(userID uint64, videoIDList []uint64) ([]bool, error)
GetFavoriteStatusList 获取用户对一批视频的点赞状态
func (*FavoriteService) GetFavoriteVideoIDListRedis ¶
func (f *FavoriteService) GetFavoriteVideoIDListRedis(userID uint64, videoIDList *[]uint64) error
GetFavoriteVideoIDListRedis 获取用户的点赞视频ID列表
func (*FavoriteService) GetFavoriteVideoListByUserIDSql ¶
func (f *FavoriteService) GetFavoriteVideoListByUserIDSql(userID uint64, videoList *[]system.Video) error
GetFavoriteVideoListByUserIDSql 查询用户的点赞列表
func (*FavoriteService) GetFavoriteVideoListRedis ¶
func (f *FavoriteService) GetFavoriteVideoListRedis(userID uint64, videoList *[]system.Video) error
GetFavoriteVideoListRedis 获取用户的点赞视频列表
func (*FavoriteService) GetVideoFavoriteStatusByUserIDRedis ¶
func (f *FavoriteService) GetVideoFavoriteStatusByUserIDRedis(userID, videoID uint64) (bool, error)
GetVideoFavoriteStatusByUserIDRedis 获取用户对视频的点赞状态
func (*FavoriteService) SetFavoriteVideoIDListRedis ¶
func (f *FavoriteService) SetFavoriteVideoIDListRedis(userID uint64, listZ ...*redis.Z) error
SetFavoriteVideoIDListRedis 将用户点赞过的视频ID列表加入缓存
func (*FavoriteService) SetUserFavoriteEmpty ¶
func (f *FavoriteService) SetUserFavoriteEmpty(userID uint64) error
SetUserFavoriteEmpty 设置用户点赞视频列表为空的空值缓存处理
func (*FavoriteService) SetVideoCommentEmpty ¶
func (f *FavoriteService) SetVideoCommentEmpty(videoID uint64) error
SetVideoCommentEmpty 设置视频评论列表为空的空值缓存处理
func (*FavoriteService) SubVideoFavoriteRedis ¶
func (f *FavoriteService) SubVideoFavoriteRedis(userID, videoID uint64)
SubVideoFavoriteRedis 取消点赞成功后,如果缓存存在,更新视频被点赞数,用户点赞列表
type FeedService ¶
type FeedService struct { }
func (*FeedService) GetAuthorIDByVideoID ¶
func (f *FeedService) GetAuthorIDByVideoID(videoID uint64) (authorID uint64, err error)
func (*FeedService) GetFeedVideoListRedis ¶
func (f *FeedService) GetFeedVideoListRedis(videoList *[]system.Video, authorList *[]system.User, latestTime string) error
GetFeedVideoListRedis 拉取视频数据,返回按投稿时间倒序的视频列表
func (*FeedService) GetStartTime ¶
func (f *FeedService) GetStartTime(startTime string) string
GetStartTime 获取视频流Feed时间戳参数处理
func (*FeedService) GetVideoListByVideoIDListRedis ¶
func (f *FeedService) GetVideoListByVideoIDListRedis(videoList *[]system.Video, videoIDList []uint64) error
GetVideoListByVideoIDListRedis 根据视频ID列表从缓存中查找视频信息
func (*FeedService) GetVideoListByVideoIDListSql ¶
func (f *FeedService) GetVideoListByVideoIDListSql(videoList *[]system.Video, videoIDList []uint64) error
GetVideoListByVideoIDListSql 当缓存未命中时,根据视频ID列表从数据库查询数据,并写入缓存
func (*FeedService) SetFeedCache ¶
func (f *FeedService) SetFeedCache() error
SetFeedCache 使用有序集合 zset 记录所有发布过的视频(key:"feed",score:视频创建的时间戳,value:video_id)
func (*FeedService) SetVideoListRedis ¶
func (f *FeedService) SetVideoListRedis(videoList []system.Video) error
SetVideoListRedis 将视频信息列表批量写入缓存
type PublishService ¶
type PublishService struct { }
func (*PublishService) CheckVideo ¶
func (p *PublishService) CheckVideo(data *multipart.FileHeader, title string) (*comRes.Response, error)
CheckVideo 参数合法性校验
func (*PublishService) CreateVideo ¶
func (p *PublishService) CreateVideo(video *system.Video) error
CreateVideo 将用户发布的视频写入数据库
func (*PublishService) GetPublishedVideoListRedis ¶
func (p *PublishService) GetPublishedVideoListRedis(userID uint64, videoList *[]system.Video) error
GetPublishedVideoListRedis 查询用户的发布视频列表
func (*PublishService) GetVideoListByUserIDSql ¶
func (p *PublishService) GetVideoListByUserIDSql(userID uint64, videoList *[]system.Video) error
GetVideoListByUserIDSql 缓存不存在时,获取用户的发布视频列表
func (*PublishService) LocalSave ¶
func (p *PublishService) LocalSave(c *gin.Context, data *multipart.FileHeader, userId uint64) (string, string, error)
LocalSave 视频保存服务器本地
func (*PublishService) OssUpload ¶
func (p *PublishService) OssUpload(data *multipart.FileHeader, video, image string) (string, string, error)
OssUpload 阿里云oss对象存储
func (*PublishService) SetPublishedVideoIDListRedis ¶
func (p *PublishService) SetPublishedVideoIDListRedis(userID uint64, listZ ...*redis.Z) error
SetPublishedVideoIDListRedis 将用户发布过的视频ID列表加入缓存
func (*PublishService) SetUserPublishEmpty ¶
func (p *PublishService) SetUserPublishEmpty(userID uint64) error
SetUserPublishEmpty 设置用户发布视频列表为空的空值缓存处理
func (*PublishService) SetVideoListRedis ¶
func (p *PublishService) SetVideoListRedis(videoList []system.Video) error
SetVideoListRedis 将视频信息列表批量写入缓存
type RelationService ¶
type RelationService struct { }
func (*RelationService) AddRelationAction ¶
func (r *RelationService) AddRelationAction(fromUserID, toUserID uint64) error
AddRelationAction 关注操作
func (*RelationService) AddUserFollowRedis ¶
func (r *RelationService) AddUserFollowRedis(fromUserID, toUserID uint64)
AddUserFollowRedis 关注成功后,如果缓存存在,更新用户关注数,用户关注列表
func (*RelationService) CancelRelationAction ¶
func (r *RelationService) CancelRelationAction(fromUserID, toUserID uint64) error
CancelRelationAction 取消关注
func (*RelationService) GetFollowStatus ¶
func (r *RelationService) GetFollowStatus(fromUserID, toUserID uint64) (bool, error)
GetFollowStatus 获取当前用户对某用户的关注状态
func (*RelationService) GetFollowStatusList ¶
func (r *RelationService) GetFollowStatusList(userID uint64, authorIDList []uint64) ([]bool, error)
GetFollowStatusList 获取用户对一批视频作者的关注状态
func (*RelationService) GetFollowUserIDListRedis ¶
func (r *RelationService) GetFollowUserIDListRedis(userID uint64, followUserIDList *[]uint64) error
GetFollowUserIDListRedis 获取用户的关注用户ID列表
func (*RelationService) GetFollowUserListRedis ¶
func (r *RelationService) GetFollowUserListRedis(userID uint64, followUserList *[]system.User) error
GetFollowUserListRedis 获取用户的关注列表
func (*RelationService) GetFollowUserListSql ¶
func (r *RelationService) GetFollowUserListSql(fromUserID uint64, followUserList *[]system.User) error
GetFollowUserListSql 查询用户的关注列表
func (*RelationService) GetFollowerUserListRedis ¶
func (r *RelationService) GetFollowerUserListRedis(userID uint64, followerUserList *[]system.User) error
GetFollowerUserListRedis 获取用户的粉丝列表
func (*RelationService) GetFollowerUserListSql ¶
func (r *RelationService) GetFollowerUserListSql(toUserID uint64, followerUserList *[]system.User) error
GetFollowerUserListSql 查询用户的粉丝列表
func (*RelationService) GetUserFollowStatusByUserIDRedis ¶
func (r *RelationService) GetUserFollowStatusByUserIDRedis(fromUserID, toUserID uint64) (bool, error)
GetUserFollowStatusByUserIDRedis 获取用户对另一用户的关注状态
func (*RelationService) SetFollowUserIDListRedis ¶
func (r *RelationService) SetFollowUserIDListRedis(userID uint64, listZ ...*redis.Z) error
SetFollowUserIDListRedis 将用户关注的用户ID列表加入缓存
func (*RelationService) SetFollowerUserIDListRedis ¶
func (r *RelationService) SetFollowerUserIDListRedis(userID uint64, listZ ...*redis.Z) error
SetFollowerUserIDListRedis 将用户的粉丝ID列表加入缓存
func (*RelationService) SetUserFollowEmpty ¶
func (r *RelationService) SetUserFollowEmpty(userID uint64) error
SetUserFollowEmpty 设置用户关注列表为空的空值缓存处理
func (*RelationService) SetUserFollowerEmpty ¶
func (r *RelationService) SetUserFollowerEmpty(userID uint64) error
SetUserFollowerEmpty 设置用户粉丝列表为空的空值缓存处理
func (*RelationService) SubUserFollowRedis ¶
func (r *RelationService) SubUserFollowRedis(fromUserID, toUserID uint64)
SubUserFollowRedis 取消关注成功后,如果缓存存在,更新用户关注数,用户关注列表
type ServiceGroup ¶
type ServiceGroup struct { UserService FeedService RelationService FavoriteService CommentService PublishService }
type UserService ¶
type UserService struct { }
func (*UserService) GetUserInfoByUserIDListSql ¶
func (u *UserService) GetUserInfoByUserIDListSql(userID uint64, userInfo *system.User) error
GetUserInfoByUserIDListSql 当缓存未命中时,根据用户ID从数据库中查询对应的用户信息,并写入缓存
func (*UserService) GetUserInfoByUserIDRedis ¶
func (u *UserService) GetUserInfoByUserIDRedis(userID uint64, userInfo *system.User) error
GetUserInfoByUserIDRedis 查询单个用户详细信息
func (*UserService) GetUserListByIDListRedis ¶
func (u *UserService) GetUserListByIDListRedis(authorList *[]system.User, authorIDList []uint64) error
GetUserListByIDListRedis 根据用户ID列表查找一批用户信息
func (*UserService) GetUserListByUserIDListSql ¶
func (u *UserService) GetUserListByUserIDListSql(userList *[]system.User, userIDList []uint64) error
GetUserListByUserIDListSql 当缓存未命中时,根据用户ID列表从数据库中查询对应的用户信息,并写入缓存
func (*UserService) IsLegal ¶
func (u *UserService) IsLegal(username, password string) error
func (*UserService) Login ¶
func (u *UserService) Login(username, password string) (*system.User, error)
Login 用户登录
func (*UserService) Register ¶
func (u *UserService) Register(username, password string) (*system.User, error)
Register 用户注册
func (*UserService) SetUserInfoToRedis ¶
func (u *UserService) SetUserInfoToRedis(user *system.User) error
SetUserInfoToRedis //将userInfo数据写入缓存
func (*UserService) SetUserListToRedis ¶
func (u *UserService) SetUserListToRedis(userList *[]system.User) error
SetUserListToRedis 将用户信息批量写入缓存