model

package
v0.0.0-...-f1d9293 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Db *gorm.DB

Functions

func GetCommentCount

func GetCommentCount(video Video) int64

获取视频评论数

func GetDB

func GetDB() *gorm.DB

GetDB:返回db

func GetFavoriteCount

func GetFavoriteCount(videoid int64) (int64, error)

获取视频点赞数

func GetFollowCount

func GetFollowCount(user User) int64

用户部分 获取关注数

func GetFollowerCount

func GetFollowerCount(user User) int64

获取粉丝数

func GetRDB

func GetRDB() *redis.Client

GetRDB:返回redisDB

func InitDB

func InitDB() *gorm.DB

TODO:支持redis

func InitRedis

func InitRedis() error

加载redis连接

func IsFavorite

func IsFavorite(userid, videoid int64) (bool, error)

是否已点赞

func IsFollow

func IsFollow(user, author User) (bool, error)

判断是否已关注

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:用户信息

func GetUser

func GetUser(userid int64) (User, error)

获取视频作者信息

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:视频信息

func GetVideoList

func GetVideoList(latest_time int64) ([]Video, error)

获取视频列表

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL