Documentation ¶
Index ¶
- Variables
- func InitDB()
- type Comment
- type CommentDAO
- func (c *CommentDAO) AddCommentAndUpdateCount(comment *Comment) error
- func (c *CommentDAO) DeleteCommentAndUpdateCountById(commentId, videoId int64) error
- func (c *CommentDAO) QueryCommentById(id int64, comment *Comment) error
- func (c *CommentDAO) QueryCommentListByVideoId(videoId int64, comments *[]*Comment) error
- type CommonResponse
- type Message
- type MessagePushEvent
- type MessageSendEvent
- type User
- type UserInfo
- type UserInfoDAO
- func (u *UserInfoDAO) AddUserFollow(userId, userToId int64) error
- func (u *UserInfoDAO) AddUserInfo(userinfo *UserInfo) error
- func (u *UserInfoDAO) CancelUserFollow(userId, userToId int64) error
- func (u *UserInfoDAO) GetFollowListByUserId(userId int64, userList *[]*UserInfo) error
- func (u *UserInfoDAO) GetFollowerListByUserId(userId int64, userList *[]*UserInfo) error
- func (u *UserInfoDAO) IsUserExistById(id int64) bool
- func (u *UserInfoDAO) QueryUserInfoById(userId int64, userinfo *UserInfo) error
- type UserLogin
- type UserLoginDAO
- type Video
- type VideoDAO
- func (v *VideoDAO) AddVideo(video *Video) error
- func (v *VideoDAO) IsVideoExistById(id int64) bool
- func (v *VideoDAO) MinusOneFavorByUserIdAndVideoId(userId int64, videoId int64) error
- func (v *VideoDAO) PlusOneFavorByUserIdAndVideoId(userId int64, videoId int64) error
- func (v *VideoDAO) QueryFavorVideoListByUserId(userId int64, videoList *[]*Video) error
- func (v *VideoDAO) QueryVideoByVideoId(videoId int64, video *Video) error
- func (v *VideoDAO) QueryVideoCountByUserId(userId int64, count *int64) error
- func (v *VideoDAO) QueryVideoListByLimitAndTime(limit int, latestTime time.Time, videoList *[]*Video) error
- func (v *VideoDAO) QueryVideoListByUserId(userId int64, videoList *[]*Video) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrIvdPtr = errors.New("空指针错误") ErrEmptyUserList = errors.New("用户列表为空") )
View Source
var DB *gorm.DB
Functions ¶
Types ¶
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 MessagePushEvent ¶
type MessageSendEvent ¶
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) IsVideoExistById ¶
func (*VideoDAO) MinusOneFavorByUserIdAndVideoId ¶
MinusOneFavorByUserIdAndVideoId 减少一个赞
func (*VideoDAO) PlusOneFavorByUserIdAndVideoId ¶
PlusOneFavorByUserIdAndVideoId 增加一个赞
func (*VideoDAO) QueryFavorVideoListByUserId ¶
func (*VideoDAO) QueryVideoByVideoId ¶
func (*VideoDAO) QueryVideoCountByUserId ¶
Click to show internal directories.
Click to hide internal directories.