model

package
v0.0.0-...-e4e76df Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func AddFollowerCount

func AddFollowerCount(userId int64, cnt int64) error

func AddFollowingCount

func AddFollowingCount(userId int64, count int64) error

func CreateMessage

func CreateMessage(message *Message) error

func CreateUser

func CreateUser(ctx context.Context, user *User) error

func CreateUsers

func CreateUsers(ctx context.Context, users []*User) error

func CreateVideoFavorite

func CreateVideoFavorite(ctx context.Context, favorite_video_data *FavoriteVideoRelation) error

func DelCommentByID

func DelCommentByID(ctx context.Context, commentID int64, vid int64) error

func DelVideoByID

func DelVideoByID(ctx context.Context, videoID int64, authorID int64) error

func DelVideoFavorite

func DelVideoFavorite(ctx context.Context, favorite_video_data *FavoriteVideoRelation) error

func Follow

func Follow(followedId, followerId int64) error

func GetFollowedById

func GetFollowedById(myId int64) ([]int64, error)

func GetFollowerById

func GetFollowerById(myId int64) ([]int64, error)

func GetFriendListById

func GetFriendListById(myId int64) ([]int64, error)

func IfFriend

func IfFriend(myId int64, anothorId int64) bool

func InsertComment

func InsertComment(ctx context.Context, comment *Comment) error

func IsFavorite

func IsFavorite(uId int64, vId int64) bool

func IsFollow

func IsFollow(followedId, followerId int64) bool

func ReduceFollowerCount

func ReduceFollowerCount(userId int64, cnt int64) error

func ReduceFollowingCount

func ReduceFollowingCount(userId int64, count int64) error

func SaveVideo

func SaveVideo(ctx context.Context, video *Video) error

func ShowVideoFavorite

func ShowVideoFavorite(ctx context.Context, UserId uint) ([]uint, error)

func UnFollow

func UnFollow(followedId, followerId int64) error

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 用户评论数据模型

func SelectCommentByCommentID

func SelectCommentByCommentID(ctx context.Context, commentID int64) (*Comment, error)

func SelectVideoCommentListByVideoID

func SelectVideoCommentListByVideoID(ctx context.Context, videoID int64) ([]*Comment, error)

func (Comment) TableName

func (Comment) TableName() string

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 QueryLastMessageById(fromUserId int64, ToUserId int64) (*Message, error)

func QueryMessageList

func QueryMessageList(date *string, fromUserId int64, ToUserId int64) ([]*Message, error)

func (Message) TableName

func (Message) TableName() string

type Relation

type Relation struct {
	gorm.Model
	FollowedId int64 `gorm:"column:followed_id"`
	FollowerId int64 `gorm:"column:follower_id"`
}

func (*Relation) TableName

func (r *Relation) TableName() string

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

func GetPasswordByUsername(ctx context.Context, userName string) (*User, error)

func GetUserByID

func GetUserByID(ctx context.Context, userID int64) (*User, error)

func GetUserByName

func GetUserByName(ctx context.Context, userName string) (*User, error)

func GetUsersByIDs

func GetUsersByIDs(ctx context.Context, userIDs []int64) ([]*User, error)

func (User) TableName

func (User) TableName() string

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

func GetLatestTimeVideos(ctx context.Context, limit int, latestTime *int64) ([]*Video, error)

TODO 获取最近发表的视频

func GetVideoInfoById

func GetVideoInfoById(ctx context.Context, videoId int64) (*Video, error)

func GetVideoListByUserID

func GetVideoListByUserID(ctx context.Context, authorId int64) ([]*Video, error)

func (Video) TableName

func (Video) TableName() string

Jump to

Keyboard shortcuts

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