models

package
v0.0.0-...-6db71ed Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIvdPtr        = errors.New("空指针错误")
	ErrEmptyUserList = errors.New("用户列表为空")
)
View Source
var DB *gorm.DB

Functions

func InitDB

func InitDB()

Types

type Comment

type Comment struct {
	Id         int64     `json:"id"`
	UserInfoId int64     `json:"-"` //用于一对多关系的id
	VideoId    int64     `json:"-"` //一对多,视频对评论
	User       UserInfo  `json:"user" gorm:"-"`
	Content    string    `json:"content"`
	CreatedAt  time.Time `json:"-"`
	CreateDate string    `json:"create_date" gorm:"-"`
}

type CommentDAO

type CommentDAO struct {
}

func NewCommentDAO

func NewCommentDAO() *CommentDAO

func (*CommentDAO) AddCommentAndUpdateCount

func (c *CommentDAO) AddCommentAndUpdateCount(comment *Comment) error

func (*CommentDAO) DeleteCommentAndUpdateCountById

func (c *CommentDAO) DeleteCommentAndUpdateCountById(commentId, videoId int64) error

func (*CommentDAO) QueryCommentById

func (c *CommentDAO) QueryCommentById(id int64, comment *Comment) error

func (*CommentDAO) QueryCommentListByVideoId

func (c *CommentDAO) QueryCommentListByVideoId(videoId int64, comments *[]*Comment) error

type CommonResponse

type CommonResponse struct {
	StatusCode int32  `json:"status_code"`
	StatusMsg  string `json:"status_msg,omitempty"`
}

type Message

type Message struct {
	Id         int64  `json:"id,omitempty"`
	Content    string `json:"content,omitempty"`
	CreateTime string `json:"create_time,omitempty"`
}

type MessagePushEvent

type MessagePushEvent struct {
	FromUserId int64  `json:"user_id,omitempty"`
	MsgContent string `json:"msg_content,omitempty"`
}

type MessageSendEvent

type MessageSendEvent struct {
	UserId     int64  `json:"user_id,omitempty"`
	ToUserId   int64  `json:"to_user_id,omitempty"`
	MsgContent string `json:"msg_content,omitempty"`
}

type User

type User struct {
	Id            int64  `json:"id,omitempty"`
	Name          string `json:"name,omitempty"`
	FollowCount   int64  `json:"follow_count,omitempty"`
	FollowerCount int64  `json:"follower_count,omitempty"`
	IsFollow      bool   `json:"is_follow,omitempty"`
}

type UserInfo

type UserInfo struct {
	Id            int64       `json:"id" gorm:"id,omitempty"`
	Name          string      `json:"name" gorm:"name,omitempty"`
	FollowCount   int64       `json:"follow_count" gorm:"follow_count,omitempty"`
	FollowerCount int64       `json:"follower_count" gorm:"follower_count,omitempty"`
	IsFollow      bool        `json:"is_follow" gorm:"is_follow,omitempty"`
	User          *UserLogin  `json:"-"`                                     //用户与账号密码之间的一对一
	Videos        []*Video    `json:"-"`                                     //用户与投稿视频的一对多
	Follows       []*UserInfo `json:"-" gorm:"many2many:user_relations;"`    //用户之间的多对多
	FavorVideos   []*Video    `json:"-" gorm:"many2many:user_favor_videos;"` //用户与点赞视频之间的多对多
	Comments      []*Comment  `json:"-"`                                     //用户与评论的一对多
}

type UserInfoDAO

type UserInfoDAO struct {
}

func NewUserInfoDAO

func NewUserInfoDAO() *UserInfoDAO

func (*UserInfoDAO) AddUserFollow

func (u *UserInfoDAO) AddUserFollow(userId, userToId int64) error

func (*UserInfoDAO) AddUserInfo

func (u *UserInfoDAO) AddUserInfo(userinfo *UserInfo) error

func (*UserInfoDAO) CancelUserFollow

func (u *UserInfoDAO) CancelUserFollow(userId, userToId int64) error

func (*UserInfoDAO) GetFollowListByUserId

func (u *UserInfoDAO) GetFollowListByUserId(userId int64, userList *[]*UserInfo) error

func (*UserInfoDAO) GetFollowerListByUserId

func (u *UserInfoDAO) GetFollowerListByUserId(userId int64, userList *[]*UserInfo) error

func (*UserInfoDAO) IsUserExistById

func (u *UserInfoDAO) IsUserExistById(id int64) bool

func (*UserInfoDAO) QueryUserInfoById

func (u *UserInfoDAO) QueryUserInfoById(userId int64, userinfo *UserInfo) error

type UserLogin

type UserLogin struct {
	Id         int64 `gorm:"primary_key"`
	UserInfoId int64
	Username   string `gorm:"primary_key"`
	Password   string `gorm:"size:200;notnull"`
}

UserLogin 用户登录表,和UserInfo属于一对一关系

type UserLoginDAO

type UserLoginDAO struct {
}

func NewUserLoginDao

func NewUserLoginDao() *UserLoginDAO

func (*UserLoginDAO) IsUserExistByUsername

func (u *UserLoginDAO) IsUserExistByUsername(username string) bool

func (*UserLoginDAO) QueryUserLogin

func (u *UserLoginDAO) QueryUserLogin(username, password string, login *UserLogin) error

type Video

type Video struct {
	Id            int64       `json:"id,omitempty"`
	UserInfoId    int64       `json:"-"`
	Author        UserInfo    `json:"author,omitempty" gorm:"-"` //这里应该是作者对视频的一对多的关系,而不是视频对作者,故gorm不能存他,但json需要返回它
	PlayUrl       string      `json:"play_url,omitempty"`
	CoverUrl      string      `json:"cover_url,omitempty"`
	FavoriteCount int64       `json:"favorite_count,omitempty"`
	CommentCount  int64       `json:"comment_count,omitempty"`
	IsFavorite    bool        `json:"is_favorite,omitempty"`
	Title         string      `json:"title,omitempty"`
	Users         []*UserInfo `json:"-" gorm:"many2many:user_favor_videos;"`
	Comments      []*Comment  `json:"-"`
	CreatedAt     time.Time   `json:"-"`
	UpdatedAt     time.Time   `json:"-"`
}

type VideoDAO

type VideoDAO struct {
}

func NewVideoDAO

func NewVideoDAO() *VideoDAO

func (*VideoDAO) AddVideo

func (v *VideoDAO) AddVideo(video *Video) error

AddVideo 添加视频 注意:由于视频和userinfo有多对一的关系,所以传入的Video参数一定要进行id的映射处理!

func (*VideoDAO) IsVideoExistById

func (v *VideoDAO) IsVideoExistById(id int64) bool

func (*VideoDAO) MinusOneFavorByUserIdAndVideoId

func (v *VideoDAO) MinusOneFavorByUserIdAndVideoId(userId int64, videoId int64) error

MinusOneFavorByUserIdAndVideoId 减少一个赞

func (*VideoDAO) PlusOneFavorByUserIdAndVideoId

func (v *VideoDAO) PlusOneFavorByUserIdAndVideoId(userId int64, videoId int64) error

PlusOneFavorByUserIdAndVideoId 增加一个赞

func (*VideoDAO) QueryFavorVideoListByUserId

func (v *VideoDAO) QueryFavorVideoListByUserId(userId int64, videoList *[]*Video) error

func (*VideoDAO) QueryVideoByVideoId

func (v *VideoDAO) QueryVideoByVideoId(videoId int64, video *Video) error

func (*VideoDAO) QueryVideoCountByUserId

func (v *VideoDAO) QueryVideoCountByUserId(userId int64, count *int64) error

func (*VideoDAO) QueryVideoListByLimitAndTime

func (v *VideoDAO) QueryVideoListByLimitAndTime(limit int, latestTime time.Time, videoList *[]*Video) error

QueryVideoListByLimitAndTime 返回按投稿时间倒序的视频列表,并限制为最多limit个

func (*VideoDAO) QueryVideoListByUserId

func (v *VideoDAO) QueryVideoListByUserId(userId int64, videoList *[]*Video) error

Jump to

Keyboard shortcuts

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