Documentation
¶
Overview ¶
Package dao is used to offer db interface
Index ¶
- Variables
- func CreateComment(ctx context.Context, uid, vid int64, content string) error
- func CreateFavorite(ctx context.Context, uid, vid int64) error
- func CreateFollow(ctx context.Context, uid, targetID int64) error
- func CreateUser(ctx context.Context, user User) (int64, error)
- func CreateVideo(ctx context.Context, video Video) error
- func DeleteComment(ctx context.Context, uid, cid int64) error
- func DeleteFavorite(ctx context.Context, uid, vid int64) error
- func DeleteFollow(ctx context.Context, uid, targetID int64) error
- func GetSetInt64List(ctx context.Context, key string) ([]int64, error)
- func Init()
- func InitDB()
- func InitRDB()
- func MGetFavoriteVideoIDs(ctx context.Context, uid int64) (ids []int64, err error)
- func MGetFollowOrFansIDs(ctx context.Context, key string, uid int64) (ids []int64, err error)
- func QueryCommentCount(ctx context.Context, vid int64) (int64, error)
- func QueryFavoriteCount(ctx context.Context, vid int64) int64
- func QueryFollowCount(ctx context.Context, uid int64) int64
- func QueryFollowerCount(ctx context.Context, uid int64) int64
- func QueryIsFavorite(ctx context.Context, uid, vid int64) bool
- func QueryIsFollow(ctx context.Context, curID, targetID int64) bool
- func SetEXOfVideos(ctx context.Context, videoList []model.Video, key string, ...) error
- type Comment
- type User
- type Video
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DB *gorm.DB RDB *redis.Client )
Functions ¶
func CreateUser ¶
CreateUser create user info
func GetSetInt64List ¶
GetSetInt64List 通过SMembers命令获取set中的所有元素,并转化为id序列,方便后期从mysql中拿到数据
func MGetFavoriteVideoIDs ¶
func MGetFollowOrFansIDs ¶
func QueryFollowCount ¶
QueryFollowCount 使用redis(SCard命令)查询该用户的关注列表
func QueryFollowerCount ¶
QueryFollowerCount 使用redis查询该用户的粉丝列表
func QueryIsFollow ¶
QueryIsFollow 使用redis判断该用户是否已关注
Types ¶
type Comment ¶
type User ¶
type User struct { gorm.Model Name string `json:"name,omitempty"` Password string `json:"password,omitempty"` }
User 用户的字段
func GetUserByName ¶
GetUserByName get user info by username
type Video ¶
type Video struct { gorm.Model Title string `gorm:"column:title"` AuthorID int64 `gorm:"column:uid"` PlayUrl string `gorm:"column:play_url"` CoverUrl string `gorm:"column:cover_url"` }
Video 影音视频字段
func MGetVideos ¶
MGetVideos 按照时间戳降序查找所有视频
func MGetVideosFromRedis ¶
MGetVideosFromRedis 按照时间戳降序查找所有视频
Source Files
¶
Click to show internal directories.
Click to hide internal directories.