Documentation ¶
Index ¶
- Variables
- func AddMessage(ctx context.Context, currentId int64, toUserId int64, content string) error
- func AddRelation(ctx context.Context, currentId int64, toUserId int64) error
- func CreateComment(ctx context.Context, comment *CommentRaw) error
- func CreateFavorite(ctx context.Context, favorite *FavoriteRaw, videoId int64) error
- func CreateUserInfo(ctx context.Context, username string, password string) (int64, error)
- func DeleteFavorite(ctx context.Context, currentId int64, videoId int64) error
- func DeleteRelation(ctx context.Context, currentId int64, toUserId int64) error
- func Init()
- func PublishVideoData(ctx context.Context, videoData *VideoRaw) error
- func QueryCommentCountByVideoId(videoId int64) int64
- func QueryFavoriteByIds(ctx context.Context, currentId int64, videoIds []int64) (map[int64]*FavoriteRaw, error)
- func QueryFollowCount(userId int64) int64
- func QueryFollowerCount(userId int64) int64
- func QueryFriendById(ctx context.Context, currentId int64, toUserId int64) ([]int64, error)
- func QueryRelationByIds(ctx context.Context, currentId int64, toUserIds []int64) (map[int64]*RelationRaw, error)
- func QueryUserFavoritedById(ctx context.Context, userId int64) (int64, error)
- func QueryUserTotalFavorited(ctx context.Context, userId int64) int64
- func QueryVideoCountByUserId(userId int64) int64
- type CommentRaw
- type FavoriteRaw
- type MessageRaw
- type RelationRaw
- type UserRaw
- type VideoRaw
Constants ¶
This section is empty.
Variables ¶
var DB *gorm.DB
Functions ¶
func AddMessage ¶
AddMessage 添加一条消息记录
func AddRelation ¶
AddRelation 添加一条关注记录,表示currentId关注了toUserId
func CreateComment ¶
func CreateComment(ctx context.Context, comment *CommentRaw) error
CreateComment 通过一条评论创建一条评论记录并增加视频评论数
func CreateFavorite ¶
func CreateFavorite(ctx context.Context, favorite *FavoriteRaw, videoId int64) error
CreateFavorite add a record to the favorite table through a transaction, and add the number of video likes
func CreateUserInfo ¶
func DeleteFavorite ¶
DeleteFavorite Delete a record in the favorite table and reduce the number of video likes
func DeleteRelation ¶
DeleteRelation 删除由currentId到toUserId的关注记录
func PublishVideoData ¶
PublishVideoData 向video表添加一条记录
func QueryFavoriteByIds ¶
func QueryFavoriteByIds(ctx context.Context, currentId int64, videoIds []int64) (map[int64]*FavoriteRaw, error)
QueryFavoriteByIds 根据当前用户id和视频id获取点赞信息
func QueryFollowCount ¶
QueryFollowCount 根据用户id,查询该用户关注其他用户的总数
func QueryFollowerCount ¶
QueryFollowerCount 根据用户id,查询该用户粉丝的总数
func QueryFriendById ¶
QueryFriendById 通过用户id,查询与之互相关注的用户Id
func QueryRelationByIds ¶
func QueryRelationByIds(ctx context.Context, currentId int64, toUserIds []int64) (map[int64]*RelationRaw, error)
QueryRelationByIds 根据当前用户id和目标用户id获取关注信息
func QueryUserFavoritedById ¶
QueryUserFavoritedById 查询用户喜欢的视频总数
func QueryUserTotalFavorited ¶
QueryUserTotalFavorited 查询用户被点赞的总数量
func QueryVideoCountByUserId ¶
Types ¶
type CommentRaw ¶
type CommentRaw struct { gorm.Model UserId int64 `gorm:"column:user_id;not null;index:idx_userid"` VideoId int64 `gorm:"column:video_id;not null;index:idx_videoid"` Content string `gorm:"column:content;type:varchar(255);not null"` }
CommentRaw Comment Gorm Data Structures
func DeleteComment ¶
func DeleteComment(ctx context.Context, commentId int64) (*CommentRaw, error)
DeleteComment 通过评论id号删除一条评论并减少视频评论数,返回该评论
func QueryCommentByCommentIds ¶
func QueryCommentByCommentIds(ctx context.Context, commentIds []int64) ([]*CommentRaw, error)
QueryCommentByCommentIds 通过评论id查询一组评论信息
func QueryCommentByVideoId ¶
func QueryCommentByVideoId(ctx context.Context, videoId int64) ([]*CommentRaw, error)
QueryCommentByVideoId 通过视频id号倒序返回一组评论信息
func (CommentRaw) TableName ¶
func (CommentRaw) TableName() string
type FavoriteRaw ¶
type FavoriteRaw struct { gorm.Model UserId int64 `gorm:"column:user_id;not null;index:idx_userid"` VideoId int64 `gorm:"column:video_id;not null;index:idx_videoid"` }
FavoriteRaw Gorm Data Structures
func (FavoriteRaw) TableName ¶
func (FavoriteRaw) TableName() string
type MessageRaw ¶
type MessageRaw struct { gorm.Model UserId int64 `gorm:"column:user_id;not null;index:idx_userid"` ToUserId int64 `gorm:"column:to_user_id;not null;index:idx_touserid"` Content string `gorm:"column:content;not null;index:idx_content"` CreateTime int64 `gorm:"column:create_time;not null;index:idx_createtime;autoCreateTime"` // 使用时间戳秒数填充创建时间 }
MessageRaw Message Gorm Data Structures
func QueryFriendLastMessage ¶
QueryFriendLastMessage 根据用户id和目标用户id,查询最新的消息记录
func QueryMessageById ¶
QueryMessageById 根据用户id和目标用户id,查询对应的消息记录
func (MessageRaw) TableName ¶
func (MessageRaw) TableName() string
type RelationRaw ¶
type RelationRaw struct { gorm.Model UserId int64 `gorm:"column:user_id;not null;index:idx_userid"` ToUserId int64 `gorm:"column:to_user_id;not null;index:idx_touserid"` }
RelationRaw Relation Gorm Data Structures
func QueryFollowById ¶
func QueryFollowById(ctx context.Context, userId int64) ([]*RelationRaw, error)
QueryFollowById 通过用户id,查询该用户关注的用户,返回两者之间的关注记录
func QueryFollowerById ¶
func QueryFollowerById(ctx context.Context, userId int64) ([]*RelationRaw, error)
QueryFollowerById 通过用户id,查询该用户的粉丝,返回两者之间的关注记录
func (RelationRaw) TableName ¶
func (RelationRaw) TableName() string
type UserRaw ¶
type UserRaw struct { gorm.Model Name string `gorm:"column:name;index:idx_username,unique;type:varchar(32);not null"` Password string `gorm:"column:password;type:varchar(32);not null"` Avatar string `gorm:"column:avatar;type:varchar(128);not null"` BackgroundImage string `gorm:"column:backGround;type:varchar(128);not null"` Signature string `gorm:"column:signature;type:varchar(128);not null"` }
UserRaw User Gorm Data structures
func QueryUserByIds ¶
QueryUserByIds 根据用户id获取用户信息
type VideoRaw ¶
type VideoRaw struct { gorm.Model UserId int64 `gorm:"column:user_id;not null;index:idx_userid"` Title string `gorm:"column:title;type:varchar(128);not null"` PlayUrl string `gorm:"column:play_url;varchar(128);not null"` CoverUrl string `gorm:"column:cover_url;varchar(128);not null"` UpdatedAt time.Time `gorm:"column:update_time;not null;index:idx_update"` }
VideoRaw Video Gorm Data Structures
func QueryVideoByLatestTime ¶
QueryVideoByLatestTime query video info by latest create Time
func QueryVideoByUserId ¶
QueryVideoByUserId 新增通过用户id获取视频数据的功能
func QueryVideoByVideoIds ¶
QueryVideoByVideoIds query video info by video ids