Documentation ¶
Index ¶
- Variables
- func CreateComment(ctx context.Context, comment *Comment) error
- func CreateMessagesByList(ctx context.Context, messages []*Message) error
- func CreateRelation(ctx context.Context, userID int64, toUserID int64) error
- func CreateUser(ctx context.Context, user *User) error
- func CreateVideo(ctx context.Context, video *Video) error
- func CreateVideoFavorite(ctx context.Context, userID int64, videoID int64, authorID int64) error
- func DelCommentByID(ctx context.Context, commentID int64, vid int64) error
- func DelFavoriteByUserVideoID(ctx context.Context, userID int64, videoID int64, authorID int64) error
- func DelRelationByUserIDs(ctx context.Context, userID int64, toUserID int64) error
- func DelVideoByID(ctx context.Context, videoID int64, authorID int64) error
- func GetDB() *gorm.DB
- type Comment
- type FavoriteCommentRelation
- type FavoriteVideoRelation
- func GetAllFavoriteList(ctx context.Context) ([]*FavoriteVideoRelation, error)
- func GetFavoriteListByUserID(ctx context.Context, userID int64) ([]*FavoriteVideoRelation, error)
- func GetFavoriteVideoRelationByUserVideoID(ctx context.Context, userID int64, videoID int64) (*FavoriteVideoRelation, error)
- type FollowRelation
- func GetFollowerListByUserID(ctx context.Context, toUserID int64) ([]*FollowRelation, error)
- func GetFollowingListByUserID(ctx context.Context, userID int64) ([]*FollowRelation, error)
- func GetFriendList(ctx context.Context, userID int64) ([]*FollowRelation, error)
- func GetRelationByUserIDs(ctx context.Context, userID int64, toUserID int64) (*FollowRelation, error)
- type Message
- func GetFriendLatestMessage(ctx context.Context, userID int64, toUserID int64) (*Message, error)
- func GetMessageByID(ctx context.Context, messageID int64) (*Message, error)
- func GetMessageIDsByUserIDs(ctx context.Context, userID int64, toUserID int64) ([]*Message, error)
- func GetMessagesByUserIDs(ctx context.Context, userID int64, toUserID int64, lastTimestamp int64) ([]*Message, error)
- func GetMessagesByUserToUser(ctx context.Context, userID int64, toUserID int64, lastTimestamp int64) ([]*Message, error)
- type User
- type Video
- func GetVideoById(ctx context.Context, videoID int64) (*Video, error)
- func GetVideoListByIDs(ctx context.Context, videoIDs []int64) ([]*Video, error)
- func GetVideosByUserID(ctx context.Context, authorId int64) ([]*Video, error)
- func MGetVideos(ctx context.Context, limit int, latestTime *int64) ([]*Video, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var (
DB *gorm.DB
)
Functions ¶
func CreateMessagesByList ¶
func CreateVideoFavorite ¶
func DelRelationByUserIDs ¶
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"` }
func GetCommentByCommentID ¶
type FavoriteCommentRelation ¶
type FavoriteCommentRelation struct { Comment Comment `gorm:"foreignkey:CommentID;" json:"comment,omitempty"` CommentID uint `gorm:"column:comment_id;index:idx_commentid;not null" json:"video_id"` User User `gorm:"foreignkey:UserID;" json:"user,omitempty"` UserID uint `gorm:"column:user_id;index:idx_userid;not null" json:"user_id"` }
func (FavoriteCommentRelation) TableName ¶
func (FavoriteCommentRelation) TableName() string
type FavoriteVideoRelation ¶
type FavoriteVideoRelation struct { 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"` }
func GetAllFavoriteList ¶
func GetAllFavoriteList(ctx context.Context) ([]*FavoriteVideoRelation, error)
func GetFavoriteListByUserID ¶
func GetFavoriteListByUserID(ctx context.Context, userID int64) ([]*FavoriteVideoRelation, error)
func (FavoriteVideoRelation) TableName ¶
func (FavoriteVideoRelation) TableName() string
type FollowRelation ¶
type FollowRelation struct { gorm.Model User User `gorm:"foreignkey:UserID;" json:"user,omitempty"` UserID uint `gorm:"index:idx_userid;not null" json:"user_id"` ToUser User `gorm:"foreignkey:ToUserID;" json:"to_user,omitempty"` ToUserID uint `gorm:"index:idx_userid;index:idx_userid_to;not null" json:"to_user_id"` }
func GetFollowerListByUserID ¶
func GetFollowerListByUserID(ctx context.Context, toUserID int64) ([]*FollowRelation, error)
func GetFollowingListByUserID ¶
func GetFollowingListByUserID(ctx context.Context, userID int64) ([]*FollowRelation, error)
GetFollowingListByUserID
@Description: 获取指定用户的关注关系列表 @Date 2023-01-21 17:01:40 @param ctx 数据库操作上下文 @param userID 指定用户的用户id @return []*Relation 指定用户的关注关系列表 @return error
func GetFriendList ¶
func GetFriendList(ctx context.Context, userID int64) ([]*FollowRelation, error)
func GetRelationByUserIDs ¶
func (FollowRelation) TableName ¶
func (FollowRelation) TableName() string
type Message ¶
type Message struct { ID uint `gorm:"primarykey"` CreatedAt time.Time `gorm:"index;not null" json:"create_time"` UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` FromUser User `gorm:"foreignkey:FromUserID;" json:"from_user,omitempty"` FromUserID uint `gorm:"index:idx_userid_from;not null" json:"from_user_id"` ToUser User `gorm:"foreignkey:ToUserID;" json:"to_user,omitempty"` ToUserID uint `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"` }
func GetFriendLatestMessage ¶
func GetMessageIDsByUserIDs ¶
func GetMessagesByUserIDs ¶
func GetMessagesByUserToUser ¶
type User ¶
type User struct { gorm.Model UserName string `gorm:"index:idx_username,unique;type:varchar(40);not null" json:"name,omitempty"` Password string `gorm:"type:varchar(256);not null" json:"password,omitempty"` FavoriteVideos []Video `gorm:"many2many:user_favorite_videos" json:"favorite_videos,omitempty"` FollowingCount uint `gorm:"default:0;not null" json:"follow_count,omitempty"` // 关注总数 FollowerCount uint `gorm:"default:0;not null" json:"follower_count,omitempty"` // 粉丝总数 Avatar string `gorm:"type:varchar(256)" json:"avatar,omitempty"` // 用户头像 BackgroundImage string `gorm:"column:background_image;type:varchar(256);default:default_background.jpg" json:"background_image,omitempty"` // 用户个人页顶部大图 WorkCount uint `gorm:"default:0;not null" json:"work_count,omitempty"` // 作品数 FavoriteCount uint `gorm:"default:0;not null" json:"favorite_count,omitempty"` // 喜欢数 TotalFavorited uint `gorm:"default:0;not null" json:"total_favorited,omitempty"` // 获赞总量 Signature string `gorm:"type:varchar(256)" json:"signature,omitempty"` // 个人简介 }
func GetUserByUserName ¶
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"` Author User `gorm:"foreignkey:AuthorID" json:"author,omitempty"` 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 GetVideoListByIDs ¶
func GetVideosByUserID ¶
func MGetVideos ¶
Click to show internal directories.
Click to hide internal directories.