Documentation ¶
Index ¶
- Variables
- func AddFollowerCount(userId int64, cnt int64) error
- func AddFollowingCount(userId int64, count int64) error
- func CreateMessage(message *Message) error
- func CreateUser(ctx context.Context, user *User) error
- func CreateUsers(ctx context.Context, users []*User) error
- func CreateVideoFavorite(ctx context.Context, favorite_video_data *FavoriteVideoRelation) error
- func DelCommentByID(ctx context.Context, commentID int64, vid int64) error
- func DelVideoByID(ctx context.Context, videoID int64, authorID int64) error
- func DelVideoFavorite(ctx context.Context, favorite_video_data *FavoriteVideoRelation) error
- func Follow(followedId, followerId int64) error
- func GetFollowedById(myId int64) ([]int64, error)
- func GetFollowerById(myId int64) ([]int64, error)
- func GetFriendListById(myId int64) ([]int64, error)
- func IfFriend(myId int64, anothorId int64) bool
- func InsertComment(ctx context.Context, comment *Comment) error
- func IsFavorite(uId int64, vId int64) bool
- func IsFollow(followedId, followerId int64) bool
- func ReduceFollowerCount(userId int64, cnt int64) error
- func ReduceFollowingCount(userId int64, count int64) error
- func SaveVideo(ctx context.Context, video *Video) error
- func ShowVideoFavorite(ctx context.Context, UserId uint) ([]uint, error)
- func UnFollow(followedId, followerId int64) error
- type Comment
- type FavoriteVideoRelation
- type Message
- type Relation
- type User
- type Video
Constants ¶
This section is empty.
Variables ¶
View Source
var DB *gorm.DB
Functions ¶
func AddFollowerCount ¶
func AddFollowingCount ¶
func CreateMessage ¶
func CreateVideoFavorite ¶
func CreateVideoFavorite(ctx context.Context, favorite_video_data *FavoriteVideoRelation) error
func DelVideoFavorite ¶
func DelVideoFavorite(ctx context.Context, favorite_video_data *FavoriteVideoRelation) error
func GetFollowedById ¶
func GetFollowerById ¶
func GetFriendListById ¶
func IsFavorite ¶
func ReduceFollowerCount ¶
func ReduceFollowingCount ¶
Types ¶
type Comment ¶
type Comment struct { ID uint `gorm:"primarykey"` CreatedAt time.Time `gorm:"index;not null" json:"create_date"` UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` Video Video `gorm:"foreignkey:VideoID" json:"video,omitempty"` VideoID uint `gorm:"index:idx_videoid;not null" json:"video_id"` User User `gorm:"foreignkey:UserID" json:"user,omitempty"` UserID uint `gorm:"index:idx_userid;not null" json:"user_id"` Content string `gorm:"type:varchar(255);not null" json:"content"` LikeCount uint `gorm:"column:like_count;default:0;not null" json:"like_count,omitempty"` TeaseCount uint `gorm:"column:tease_count;default:0;not null" json:"tease_count,omitempty"` }
TODO 用户评论数据模型
type FavoriteVideoRelation ¶
type FavoriteVideoRelation struct { // Video Video `gorm:"foreignkey:VideoID;" json:"video,omitempty"` UserID uint `gorm:"index:idx_userid;not null" json:"user_id"` VideoID uint `gorm:"index:idx_videoid;not null" json:"video_id"` }
func (FavoriteVideoRelation) TableName ¶
func (FavoriteVideoRelation) TableName() string
type Message ¶
type Message struct { ID int64 `gorm:"primarykey"` FromUserID int64 `gorm:"index:idx_userid_from;not null" json:"from_user_id"` ToUserID int64 `gorm:"index:idx_userid_from;index:idx_userid_to;not null" json:"to_user_id"` Content string `gorm:"type:varchar(255);not null" json:"content"` CreatedAt time.Time `gorm:"index;not null" json:"created_at"` UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` }
func QueryLastMessageById ¶
func QueryMessageList ¶
type Relation ¶
type User ¶
type User struct { gorm.Model UserName string `gorm:"index:idx_username,unique;type:varchar(40);not null" json:"name"` Password string `gorm:"type:varchar(256);not null" json:"password"` // FavoriteVideos []Video `gorm:"many2many:user_favorite_videos" json:"favorite_videos"` FollowingCount uint `gorm:"default:0;not null" json:"follow_count"` // 关注总数 FollowerCount uint `gorm:"default:0;not null" json:"follower_count"` // 粉丝总数 Avatar string `gorm:"type:varchar(256)" json:"avatar"` // 用户头像 BackgroundImage string `gorm:"column:background_image;type:varchar(256);default:default_background.jpg" json:"background_image"` // 用户个人页顶部大图 WorkCount uint `gorm:"default:0;not null" json:"work_count"` // 作品数 FavoriteCount uint `gorm:"default:0;not null" json:"favorite_count"` // 喜欢数 TotalFavorited uint `gorm:"default:0;not null" json:"total_favorited"` // 获赞总量 Signature string `gorm:"type:varchar(256)" json:"signature"` // 个人简介 }
func GetPasswordByUsername ¶
type Video ¶
type Video struct { ID uint `gorm:"primarykey"` CreatedAt time.Time `gorm:"not null;index:idx_create" json:"created_at,omitempty"` UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` AuthorID uint `gorm:"index:idx_authorid;not null" json:"author_id,omitempty"` PlayUrl string `gorm:"type:varchar(255);not null" json:"play_url,omitempty"` CoverUrl string `gorm:"type:varchar(255)" json:"cover_url,omitempty"` FavoriteCount uint `gorm:"default:0;not null" json:"favorite_count,omitempty"` CommentCount uint `gorm:"default:0;not null" json:"comment_count,omitempty"` Title string `gorm:"type:varchar(50);not null" json:"title,omitempty"` }
func GetLatestTimeVideos ¶
TODO 获取最近发表的视频
func GetVideoListByUserID ¶
Click to show internal directories.
Click to hide internal directories.