repository

package
v0.0.0-...-c93c141 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const MaxListLength = 30

Variables

This section is empty.

Functions

func Init

func Init() error

Init 初始化数据库连接操作

Types

type Comment

type Comment struct {
	ID         int64
	UserID     int64
	VideoID    int64
	Content    string
	CreateTime time.Time `gorm:"default:CURRENT_TIMESTAMP"`
}

type CommentDao

type CommentDao struct {
}

func NewCommentDaoInstance

func NewCommentDaoInstance() *CommentDao

NewCommentDaoInstance 返回一个评论表实体类的指针变量,可以方便调用该结构体的方法

func (*CommentDao) CreateComment

func (c *CommentDao) CreateComment(userId, videoId int64, commentText string) (int64, error)

CreateComment 新增评论返回评论id

func (*CommentDao) DeleteComment

func (c *CommentDao) DeleteComment(commentId, videoId int64) error

DeleteComment 删除评论

func (*CommentDao) QueryCommentById

func (c *CommentDao) QueryCommentById(commentId int64) (*Comment, error)

QueryCommentById 通过id查询评论

func (*CommentDao) QueryCommentsByVideoId

func (c *CommentDao) QueryCommentsByVideoId(videoId int64) ([]Comment, error)

QueryCommentsByVideoId 通过视频id查询该视频所有评论

type Favorite

type Favorite struct {
	ID         int64
	UserID     int64
	VideoID    int64
	IsFavorite int32 `gorm:"default:0"`
}

type FavoriteDao

type FavoriteDao struct {
}

func NewFavoriteDaoInstance

func NewFavoriteDaoInstance() *FavoriteDao

NewFavoriteDaoInstance 返回一个点赞表实体类的指针变量,可以方便调用该结构体的方法

func (*FavoriteDao) CreateFavorite

func (f *FavoriteDao) CreateFavorite(userId int64, videoId int64, actionType int32) error

CreateFavorite 创建点赞关联记录

func (*FavoriteDao) QueryActionTypeByUserIdAndVideoId

func (f *FavoriteDao) QueryActionTypeByUserIdAndVideoId(userId, videoId int64) (int32, error)

QueryActionTypeByUserIdAndVideoId 通过用户id和视频id获取该用户对于这个视频是否点赞的状态码

func (*FavoriteDao) QueryFavoriteByUserIdAndVideoId

func (f *FavoriteDao) QueryFavoriteByUserIdAndVideoId(userId int64, videoId int64) (bool, error)

QueryFavoriteByUserIdAndVideoId 查询是否包含对应点赞关联记录

func (*FavoriteDao) QueryFavoriteCountByUserId

func (f *FavoriteDao) QueryFavoriteCountByUserId(userId int64) (int64, error)

QueryFavoriteCountByUserId 根据用户id查询用户点赞视频的数量

func (*FavoriteDao) QueryVideosIdByUserId

func (f *FavoriteDao) QueryVideosIdByUserId(userId int64) ([]int64, error)

QueryVideosIdByUserId 通过用户id查询查询该用户点赞的所有视频对应的视频id列表

func (*FavoriteDao) UpdateFavorite

func (f *FavoriteDao) UpdateFavorite(userId int64, videoId int64, actionType int32) error

UpdateFavorite 更新点赞关联记录

type Relation

type Relation struct {
	ID          int64
	UserID      int64 `gorm:"default:0"`
	FollowingID int64 `gorm:"default:0"`
}

type RelationDao

type RelationDao struct {
}

func NewRelationDaoInstance

func NewRelationDaoInstance() *RelationDao

NewRelationDaoInstance 返回一个评论表实体类的指针变量,可以方便调用该结构体的方法

func (*RelationDao) CreateRelation

func (r *RelationDao) CreateRelation(userId, toUserId int64) error

CreateRelation 新增关注记录信息

func (*RelationDao) DeleteRelation

func (r *RelationDao) DeleteRelation(userId, toUserId int64) error

DeleteRelation 删除关注记录信息

func (*RelationDao) QueryFollowIdsByUserId

func (r *RelationDao) QueryFollowIdsByUserId(userId int64) ([]int64, error)

QueryFollowIdsByUserId 通过用户id查询该用户关注的所有用户的id

func (*RelationDao) QueryFollowerIdsByUserId

func (r *RelationDao) QueryFollowerIdsByUserId(userId int64) ([]int64, error)

QueryFollowerIdsByUserId 通过用户id查询该用户所有粉丝的用户id

func (*RelationDao) QueryIsFollowByUserIdAndToUserId

func (r *RelationDao) QueryIsFollowByUserIdAndToUserId(userId, toUserId int64) (bool, error)

QueryIsFollowByUserIdAndToUserId 通过登录用户id和视频发布者id获取该登录用户是否关注视频所有者

type User

type User struct {
	Id              int64  `gorm:"primary_key"`
	Name            string `gorm:"column:name;size:32;not null"`
	Password        string `gorm:"column:password;size:32;"`
	FollowCount     int64  `gorm:"column:follow_count"`
	FollowerCount   int64  `gorm:"column:follower_count"`
	Avatar          string
	Signature       string
	BackgroundImage string
}

type UserDao

type UserDao struct {
}

func NewUserDaoInstance

func NewUserDaoInstance() *UserDao

NewUserDaoInstance 返回一个用户实体类的指针变量,可以方便调用该结构体的方法

func (*UserDao) CreateByNameAndPassword

func (u *UserDao) CreateByNameAndPassword(name, password string) (*User, error)

CreateByNameAndPassword 通过用户名和密码创建新用户

func (*UserDao) QueryIsContainsUserName

func (u *UserDao) QueryIsContainsUserName(name string) (bool, error)

QueryIsContainsUserName 查询用户名是否存在

func (*UserDao) QueryLoginInfo

func (u *UserDao) QueryLoginInfo(name string) (*User, error)

QueryLoginInfo 通过用户名查询此用户信息

func (*UserDao) QueryUserById

func (u *UserDao) QueryUserById(userId int64) (*User, error)

QueryUserById 通过用户id查询详细的用户信息

func (*UserDao) QueryUsersByIds

func (u *UserDao) QueryUsersByIds(ids []int64) ([]User, error)

QueryUsersByIds 通过一组用户id查询一组用户信息

type Video

type Video struct {
	Id            int64     `gorm:"primaryKey"`
	PlayUrl       string    `gorm:"size:64"`
	CoverUrl      string    `gorm:"size:64"`
	FavoriteCount int64     `gorm:"column:favorite_count"`
	CommentCount  int64     `gorm:"column:comment_count"`
	Title         string    `gorm:"column:title;size:32"`
	UserId        int64     `gorm:"column:user_id"`
	CreateTime    time.Time `gorm:"default:CURRENT_TIMESTAMP"`
}

type VideoDao

type VideoDao struct {
}

func NewVideoDaoInstance

func NewVideoDaoInstance() *VideoDao

NewVideoDaoInstance 返回一个视频实体类的指针变量,可以方便调用该结构体的方法

func (*VideoDao) CreateVideoRecord

func (d *VideoDao) CreateVideoRecord(userId int64, playURL string, coverURL string, title string) error

CreateVideoRecord 通过传入参数创建新的视频记录

func (*VideoDao) QueryByIds

func (d *VideoDao) QueryByIds(ids []int64) ([]Video, error)

QueryByIds 通过一组视频id获取对应的视频列表

func (*VideoDao) QueryByOwner

func (d *VideoDao) QueryByOwner(ownerId int64) ([]Video, error)

QueryByOwner 通过用户id查询该用户发布的所有视频

func (*VideoDao) QueryFeedFlow

func (d *VideoDao) QueryFeedFlow(latestTime string) ([]Video, error)

QueryFeedFlow 通过当前时间查询这个时间前新发布的50条视频,逆序输出

func (*VideoDao) QueryPublishCountByUserId

func (d *VideoDao) QueryPublishCountByUserId(userId int64) (int64, error)

QueryPublishCountByUserId 通过用户id查询该用户发布的视频数量

func (*VideoDao) QueryTotalFavoriteCountByUserId

func (d *VideoDao) QueryTotalFavoriteCountByUserId(userId int64) (int64, error)

QueryTotalFavoriteCountByUserId 通过用户id查询该用户发布的所有视频总获赞数量

Jump to

Keyboard shortcuts

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