db

package
v0.0.0-...-542fe02 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func CreateUser

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

CreateUser create user info

func GetWorkCountByUserId

func GetWorkCountByUserId(user_id int64) (int64, error)

func Init

func Init()

Init init DB

Types

type Favorite

type Favorite struct {
	gorm.Model
	UserId  int64 `json:"user_id"`
	VideoId int64 `json:"video_id"`
}

func (Favorite) TableName

func (u Favorite) TableName() string

type User

type User struct {
	gorm.Model
	ID              int64  `gorm:"primaryKey";json:"id"`
	UserName        string `gorm:"type:varchar(255)"json:"user_name"`
	Password        string `gorm:"type:varchar(255)"json:"password"`
	Avatar          string `gorm:"type:varchar(255)"json:"avatar"`           // 用户头像 URL
	BackgroundImage string `gorm:"type:varchar(255)"json:"background_image"` // 用户背景图 URL
	Signature       string `gorm:"type:varchar(255)"json:"signature"`        // 用户个性签名
}

func QueryUser

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

QueryUser query list of user info

func QueryUserByUserId

func QueryUserByUserId(user_id int64) (*User, error)

QueryUserByUserId get user in the database by user id

func (User) TableName

func (u User) TableName() string

type Video

type Video struct {
	gorm.Model
	ID          int64
	AuthorID    int64
	PlayURL     string
	CoverURL    string
	PublishTime time.Time
	Title       string
}

func (Video) TableName

func (u Video) TableName() string

Jump to

Keyboard shortcuts

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