Documentation ¶
Index ¶
- Variables
- func Create(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 Delete(ctx context.Context, currentId int64, toUserId int64) error
- func DeleteFavorite(ctx context.Context, currentId int64, videoId int64) error
- func Init()
- func PublishVideoData(ctx context.Context, videoData *VideoRaw) error
- func QueryFavoriteById(ctx context.Context, userId int64) ([]int64, error)
- func QueryFavoriteByIds(ctx context.Context, currentId int64, videoIds []int64) (map[int64]*FavoriteRaw, error)
- func QueryRelationByIds(ctx context.Context, currentId int64, userIds []int64) (map[int64]*RelationRaw, error)
- func UploadUserData(ctx context.Context, username string, password string) (int64, error)
- type CommentRaw
- type FavoriteRaw
- type RelationRaw
- type UserRaw
- type VideoRaw
Constants ¶
This section is empty.
Variables ¶
var DB *gorm.DB
Functions ¶
func CreateComment ¶
func CreateComment(ctx context.Context, comment *CommentRaw) error
通过一条评论创建一条评论记录并增加视频评论数
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 DeleteFavorite ¶
DeleteFavorite Delete a record in the favorite table and reduce the number of video likes
func PublishVideoData ¶
向video表添加一条记录
func QueryFavoriteById ¶
QueryFavoriteById 通过一个用户id查询出该用户点赞的所有视频id号
func QueryFavoriteByIds ¶
func QueryFavoriteByIds(ctx context.Context, currentId int64, videoIds []int64) (map[int64]*FavoriteRaw, error)
根据当前用户id和视频id获取点赞信息
func QueryRelationByIds ¶
func QueryRelationByIds(ctx context.Context, currentId int64, userIds []int64) (map[int64]*RelationRaw, error)
根据当前用户id和目标用户id获取关注信息
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"` Contents string `grom:"column:contents;type:varchar(255);not null"` }
Comment Gorm Data Structures
func DeleteComment ¶
func DeleteComment(ctx context.Context, commentId int64) (*CommentRaw, error)
通过评论id号删除一条评论并减少视频评论数,返回该评论
func QueryCommentByCommentIds ¶
func QueryCommentByCommentIds(ctx context.Context, commentIds []int64) ([]*CommentRaw, error)
通过评论id查询一组评论信息
func QueryCommentByVideoId ¶
func QueryCommentByVideoId(ctx context.Context, videoId int64) ([]*CommentRaw, error)
通过视频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"` }
Favorite Gorm Data Structures
func (FavoriteRaw) TableName ¶
func (FavoriteRaw) 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"` }
Relation Gorm Data Structures
func QueryFollowById ¶
func QueryFollowById(ctx context.Context, userId int64) ([]*RelationRaw, error)
通过用户id,查询该用户关注的用户,返回两者之间的关注记录
func QueryFollowerById ¶
func QueryFollowerById(ctx context.Context, userId int64) ([]*RelationRaw, error)
通过用户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"` FollowCount int64 `gorm:"column:follow_count;default:0"` FollowerCount int64 `gorm:"column:follower_count;default:0"` }
User Gorm Data structures
func QueryUserByIds ¶
根据用户id获取用户信息
func QueryUserByName ¶
根据用户名获取用户信息
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"` FavoriteCount int64 `gorm:"column:favorite_count;default:0"` CommentCount int64 `gorm:"column:comment_count;default:0"` UpdatedAt time.Time `gorm:"column:update_time;not null;index:idx_update"` }
Video Gorm Data Structures
func QueryVideoByLatestTime ¶
QueryVideoByLatestTime query video info by latest create Time
func QueryVideoByUserId ¶
新增通过用户id获取视频数据的功能
func QueryVideoByVideoIds ¶
QueryVideoByVideoIds query video info by video ids