Documentation ¶
Index ¶
- Variables
- func GetCommentCount(video Video) int64
- func GetDB() *gorm.DB
- func GetFavoriteCount(videoid int64) (int64, error)
- func GetFollowCount(user User) int64
- func GetFollowerCount(user User) int64
- func GetRDB() *redis.Client
- func InitDB() *gorm.DB
- func InitRedis() error
- func IsFavorite(userid, videoid int64) (bool, error)
- func IsFollow(user, author User) (bool, error)
- type Comment
- type User
- type Video
Constants ¶
This section is empty.
Variables ¶
View Source
var Db *gorm.DB
View Source
var Rdb *redis.Client
Functions ¶
Types ¶
type Comment ¶
type Comment struct { ID int64 `gorm:"column:id;primary_key;AUTO_INCREMENT;not null"` Content string `gorm:"not null"` UserID int64 `gorm:"not null"` //评论者的id VideoID int64 `gorm:"not null"` //被评论视频的id }
Comment:视频评论
type User ¶
type User struct { ID int64 `gorm:"column:id;primary_key;AUTO_INCREMENT;not null"` Username string Password_Hash string // 加密后的密码 //用户关注列表,多对多,gorm自动生成一个中间表 Follows []*User `gorm:"many2many:user_follows;association_jointable_foreignkey:follow_id"` //该用户的关注 //粉丝列表,多对多,同样自动生成一个中间表 Followers []*User `gorm:"many2many:user_followers;association_jointable_foreignkey:follower_id"` //该用户的粉丝 //用户发布的视频,通过视频表的作者id作为外键关联 Videos []Video `gorm:"foreignkey:AuthorID"` //该用户发布的作品 //用户点赞过的视频,多对多,生成一个中间表, FavoriteVideos []Video `gorm:"many2many:user_favorite;association_jointable_foreignkey:favorite_id"` //用户点赞过的作品 }
User_info:用户信息
type Video ¶
type Video struct { ID int64 `gorm:"column:id;primary_key;AUTO_INCREMENT;not null"` Title string AuthorID int64 //作者id UpdateTime int64 //发布、更新时间 Location string //储存位置 Cover_location string //封面储存位置 //视频评论,通过评论表的用户id作为外键关联 Comments []Comment `gorm:"foreignkey:UserID"` //视频的评论 }
Video:视频信息
Click to show internal directories.
Click to hide internal directories.