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: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func Add

Add favorite

func CheckUserExistById

func CheckUserExistById(user_id int64) (bool, error)

CheckUserExistById find if user exists

func CheckVideoExistById

func CheckVideoExistById(video_id int64) (bool, error)

CheckVideoExistById query if video exist

func GetFavoriteCountByUserID

func GetFavoriteCountByUserID(user_id int64) (int64, error)

GetFavoriteCountByUserID get the num of the video liked by user

func GetFavoriteIdList

func GetFavoriteIdList(ctx context.Context, user_id int64) ([]int64, error)

func Init

func Init()

Init init DBz

func QueryFavoriteCount

func QueryFavoriteCount(ctx context.Context, video_id int64) (int64, error)

QueryFavoriteCount favorite_count video_id how many people like

func QueryIsFavorite

func QueryIsFavorite(ctx context.Context, req *favorite.IsFavoriteRequest) (bool, error)

QueryIsFavorite user_id like video_id

func QueryTotalFavoritedByAuthorID

func QueryTotalFavoritedByAuthorID(user_id int64) (int64, error)

QueryTotalFavoritedByAuthorID 获取该作者的获赞数

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"`        // 用户个性签名
}

type Video

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

func GetVideoListByVideoIDList

func GetVideoListByVideoIDList(ctx context.Context, video_id_list []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