Documentation ¶
Index ¶
- Variables
- func CreateUser(ctx context.Context, users []*User) error
- func CreateVideo(ctx context.Context, video *Video) error
- func DelComment(ctx context.Context, commentID int64, vid int64) error
- func DisFavorite(ctx context.Context, uid int64, vid int64) error
- func DisRelation(ctx context.Context, uid int64, tid int64) error
- func Favorite(ctx context.Context, uid int64, vid int64) error
- func Init()
- func InitDB()
- func NewComment(ctx context.Context, comment *Comment) error
- func NewRelation(ctx context.Context, uid int64, tid int64) error
- type Comment
- type Relation
- type User
- type Video
- func FavoriteList(ctx context.Context, uid int64) ([]Video, error)
- func GetFavoriteRelation(ctx context.Context, uid int64, vid int64) (*Video, error)
- func MGetVideos(ctx context.Context, limit int, latestTime *int64) ([]*Video, error)
- func PublishList(ctx context.Context, authorId int64) ([]*Video, error)
Constants ¶
This section is empty.
Variables ¶
var ( DB *gorm.DB Config = ttviper.ConfigInit("TIKTOK_DB", "dbConfig") )
Functions ¶
func CreateUser ¶
CreateUser create user info
func CreateVideo ¶
CreateVideo creates a new video
func DelComment ¶
DelComment deletes a comment from the database.
func DisFavorite ¶
DisFavorite deletes the specified favorite from the database
func DisRelation ¶
DisRelation deletes a relation from the database.
func NewComment ¶
NewComment creates a new Comment
Types ¶
type Comment ¶
type Comment struct { gorm.Model Video Video `gorm:"foreignkey:VideoID"` VideoID int `gorm:"index:idx_videoid;not null"` User User `gorm:"foreignkey:UserID"` UserID int `gorm:"index:idx_userid;not null"` Content string `gorm:"type:varchar(255);not null"` }
func GetVideoComments ¶
GetVideoComments returns a list of video comments.
type Relation ¶
type Relation struct { gorm.Model User User `gorm:"foreignkey:UserID;"` UserID int `gorm:"index:idx_userid,unique;not null"` ToUser User `gorm:"foreignkey:ToUserID;"` ToUserID int `gorm:"index:idx_userid,unique;index:idx_userid_to;not null"` }
Relation Gorm data structure
func FollowerList ¶
FollowerList returns the Follower List.
func FollowingList ¶
FollowingList returns the Following List.
func GetRelation ¶
GetRelation get relation info
type User ¶
type User struct { gorm.Model UserName string `gorm:"index:idx_username,unique;type:varchar(40);not null" json:"username"` Password string `gorm:"type:varchar(256);not null" json:"password"` FavoriteVideos []Video `gorm:"many2many:user_favorite_videos" json:"favorite_videos"` FollowingCount int `gorm:"default:0" json:"following_count"` FollowerCount int `gorm:"default:0" json:"follower_count"` }
User Gorm Data Structures
func GetUserByID ¶
GetUserByID multiple get list of user info
type Video ¶
type Video struct { gorm.Model UpdatedAt time.Time `gorm:"column:update_time;not null;index:idx_update" ` Author User `gorm:"foreignkey:AuthorID"` AuthorID int `gorm:"index:idx_authorid;not null"` PlayUrl string `gorm:"type:varchar(255);not null"` CoverUrl string `gorm:"type:varchar(255)"` FavoriteCount int `gorm:"default:0"` CommentCount int `gorm:"default:0"` Title string `gorm:"type:varchar(50);not null"` }
Video Gorm Data Structures
func FavoriteList ¶
FavoriteList returns a list of Favorite videos.
func GetFavoriteRelation ¶
GetFavoriteRelation get favorite video info
func MGetVideos ¶
MGetVideoss multiple get list of videos info
func PublishList ¶
PublishList returns a list of videos with AuthorID.