db

package
v0.0.0-...-8f4e997 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func CheckUserExist

func CheckUserExist(ctx context.Context, username string) (bool, error)

func CreateUser

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

func CreateUsers

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

传入用户信息内容 在数据库创建用户.

func GetUserID

func GetUserID(ctx context.Context, userName string) (int64, error)

func Init

func Init()

func IsFavorite

func IsFavorite(ctx context.Context, userID int64, vdeioID int64) error

func UserPublishAction

func UserPublishAction(ctx context.Context, userID int64, filePath string, coverPath string, title string) error

Types

type Like

type Like struct {
	gorm.Model
	ID       int64     `gorm:"column:id;primary_key;AUTO_INCREMENT"`
	LikeTime time.Time `gorm:"column:like_time;default:CURRENT_TIMESTAMP;NOT NULL"`
	UserID   int64     `gorm:"column:user_id;default:0;NOT NULL"`
	VideoID  int64     `gorm:"column:video_id;default:0;NOT NULL"`
}

func (*Like) TableName

func (v *Like) TableName() string

type User

type User struct {
	gorm.Model
	ID            int64     `gorm:"column:id;primary_key;AUTO_INCREMENT"`
	CreateTime    time.Time `gorm:"column:create_time;default:CURRENT_TIMESTAMP;NOT NULL"`
	Name          string    `gorm:"column:name;unique;NOT NULL"`
	Password      string    `gorm:"column:password;NOT NULL"`
	Salt          string    `gorm:"column:salt;NOT NULL"`
	FollowCount   int64     `gorm:"column:follow_count;default:0;NOT NULL"`
	FollowerCount int64     `gorm:"column:follower_count;default:0;NOT NULL"`
}

func GetUser

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

传入用户id 返回用户信息.

func MGetUsers

func MGetUsers(ctx context.Context, userIds []int64) ([]*User, error)

传入批量用户id 返回用户信息.

func QueryUser

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

传入用户名称 查找用户信息.

func (*User) TableName

func (u *User) TableName() string

type Video

type Video struct {
	gorm.Model
	ID            int64     `gorm:"column:id;primary_key;AUTO_INCREMENT"`
	AuthorID      int64     `gorm:"column:author_id;NOT NULL"`
	PublishTime   time.Time `gorm:"column:publish_time;default:CURRENT_TIMESTAMP;NOT NULL"`
	FilePath      string    `gorm:"column:file_path;NOT NULL"`
	CoverPath     string    `gorm:"column:cover_path;NOT NULL"`
	FavoriteCount int64     `gorm:"column:favorite_count;default:0"`
	CommentCount  int64     `gorm:"column:comment_count;default:0"`
	Title         string    `gorm:"column:title;NOT NULL"`
}

func UserGetFeed

func UserGetFeed(ctx context.Context, latestTime *int64) ([]*Video, error)

func UserPublishList

func UserPublishList(ctx context.Context, userID int32) ([]*Video, error)

func (*Video) TableName

func (v *Video) TableName() string

Jump to

Keyboard shortcuts

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