dal

package
v0.0.0-...-611b6d6 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	ID        int64     `gorm:"primary_key;auto_increment:false" json:"id"` // 评论id
	Content   string    `gorm:"type:varchar(200);not null" json:"content"`  // 评论内容
	VideoID   int64     `gorm:"type:bigint;not null"`                       // 视频id
	UserID    int64     `gorm:"type:bigint;not null"`                       // 用户id
	CreatedAt time.Time // 创建时间
}

Comment 评论表

type CommentCommand

type CommentCommand interface {
	Insert(ctx context.Context, comment *Comment) error
	Delete(ctx context.Context, id int64, uid int64, vid int64) error
}

CommentCommand is the interface for comment model operations

type CommentQuery

type CommentQuery interface {
	FindByVideoID(ctx context.Context, videoID int64, limit, offset int) ([]*Comment, error)
}

CommentQuery is the interface for comment model operations

type Like

type Like struct {
	ID        int64     `gorm:"primary_key;auto_increment:false" json:"id"` // 点赞id
	VideoID   int64     `gorm:"type:bigint;not null"`                       // 视频id
	UserID    int64     `gorm:"type:bigint;not null"`                       // 用户id
	CreatedAt time.Time // 创建时间
}

Like 点赞表

type LikeCommand

type LikeCommand interface {
	//Insert inserts a like record
	Insert(ctx context.Context, like *Like) error
	//Delete deletes a like record by video id and user id
	Delete(ctx context.Context, vid, uid int64) error
}

LikeCommand is the interface for like model operations

type LikeQuery

type LikeQuery interface {
	// FindByVideoIDAndUserID finds a like record by video id and user id
	FindByVideoIDAndUserID(ctx context.Context, vid, uid int64) (*Like, error)

	// FindVideoIDsByUserID finds video ids by user id
	FindVideoIDsByUserID(ctx context.Context, uid int64, limit, offset int) ([]int64, error)

	// FindWhetherLiked finds a like record by video id and user id
	// return a list of id that liked by userid
	FindWhetherLiked(ctx context.Context, userid int64, videoID []int64) ([]int64, error)
}

LikeQuery is the interface for like model operations

type Relation

type Relation struct {
	ID        int64     `gorm:"primary_key;auto_increment:false" json:"id"` // 点赞id
	UserID    int64     `gorm:"type:bigint;not null"`                       // 关注者id
	FollowTo  int64     `gorm:"type:bigint;not null"`                       // 被关注者id
	CreatedAt time.Time //关系创建时间
}

Relation 关系表

type RelationCommand

type RelationCommand interface {
	//Insert inserts a relation record
	Insert(ctx context.Context, rel *Relation) error
	//Delete deletes a relation record by userid and followTo
	Delete(ctx context.Context, userid, followTo int64) error
}

RelationCommand is the interface for relation model operations

type RelationQuery

type RelationQuery interface {

	// FindWhetherFollowedList finds a relation record by userid and followTo
	// return a list of id that followed by userid
	FindWhetherFollowedList(ctx context.Context, userid int64, followTo []int64) ([]int64, error)

	// FindFollowerTo finds a relation record by userid
	// which means find the user who userid follows
	// return a list of user id
	FindFollowerTo(ctx context.Context, userid int64, limit, offset int) ([]int64, error)

	// FindFollowerFrom finds a relation record by followTo
	// which means find the user who followTo is followed by
	// return a list of user id
	FindFollowerFrom(ctx context.Context, followTo int64, limit, offset int) ([]int64, error)
}

RelationQuery is the interface for relation model operations

type User

type User struct {
	ID              int64  `gorm:"primary_key;auto_increment:false" redis:"-"` // 用户id
	Username        string `gorm:"type:varchar(32);uniqueIndex" redis:"-"`     // 用户名
	Password        []byte `gorm:"type:varchar(200);not null" redis:"-"`       // 密码
	Avatar          string `gorm:"type:varchar(200)" redis:"-"`                // 头像URL
	BackgroundImage string `gorm:"type:varchar(200)" redis:"-"`                // 背景图片URL
	Signature       string `gorm:"type:varchar(200)" redis:"-"`                // 个性签名
	// 不存入数据库
	VideoCount   int64 `gorm:"-" redis:"video_count"`    // 视频数量
	LikeCount    int64 `gorm:"-" redis:"like_count"`     // 点赞数量
	FansCount    int64 `gorm:"-" redis:"fans_count"`     // 粉丝数量
	FollowCount  int64 `gorm:"-" redis:"follow_count"`   // 关注数量
	BeLikedCount int64 `gorm:"-" redis:"be_liked_count"` // 被点赞数量
}

User 用户表

type UserCommand

type UserCommand interface {
	Insert(ctx context.Context, user *User) error
	Update(ctx context.Context, user *User) error
}

UserCommand is the interface for user model operations

type UserQuery

type UserQuery interface {
	FindOne(ctx context.Context, id int64) (*User, error)
	FindMany(ctx context.Context, ids []int64) ([]*User, error)
	FindByUsername(ctx context.Context, username string) (*User, error)
}

UserQuery is the interface for user model operations

type Video

type Video struct {
	ID        int64     `gorm:"primary_key;auto_increment:false" redis:"-"` // 视频id
	UserID    int64     `gorm:"type:bigint;not null" redis:"-"`             // 用户id
	VideoURL  string    `gorm:"type:varchar(200);not null" redis:"-"`       // 视频URL
	CoverURL  string    `gorm:"type:varchar(200);not null" redis:"-"`       // 封面URL
	Title     string    `gorm:"type:varchar(200);not null" redis:"-"`       // 视频标题
	CreatedAt time.Time // 创建时间
	// 不存入数据库
	LikeCount    int64 `gorm:"-" redis:"like_count"`    // 点赞数量
	CommentCount int64 `gorm:"-" redis:"comment_count"` // 评论数量
}

Video 视频表

type VideoCommand

type VideoCommand interface {
	Insert(ctx context.Context, video *Video) error
	Update(ctx context.Context, video *Video) error
	Delete(ctx context.Context, id int64, uid int64) error
}

VideoCommand is the interface for video model operations

type VideoQuery

type VideoQuery interface {
	FindOne(ctx context.Context, id int64) (*Video, error)
	FindMany(ctx context.Context, ids []int64) ([]*Video, error)
	FindLatest(ctx context.Context, latestTime, limit int64) ([]*Video, error)
	FindByUserID(ctx context.Context, userID int64, limit, offset int) ([]*Video, error)
}

VideoQuery is the interface for video model operations

Directories

Path Synopsis
Package query data access layer
Package query data access layer

Jump to

Keyboard shortcuts

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