Documentation ¶
Index ¶
- Variables
- func AddNewComment(comment *Comment) error
- func AddNewFavorite(favorite *Favorites) (bool, error)
- func AddNewFollow(follow *Follows) (bool, error)
- func AddNewMessage(message *Messages) (bool, error)
- func CheckCommentExist(comment_id int64) (bool, error)
- func CheckUserExistById(user_id int64) (bool, error)
- func CheckVideoExistById(video_id int64) (bool, error)
- func CreateUser(user *User) (int64, error)
- func CreateVideo(video *Video) (Video_id int64, err error)
- func DeleteCommentById(comment_id int64) error
- func DeleteFavorite(favorite *Favorites) (bool, error)
- func DeleteFollow(follow *Follows) (bool, error)
- func GetCommentCountByVideoID(video_id int64) (int64, error)
- func GetFavoriteCount(video_id int64) (int64, error)
- func GetFavoriteCountByUserID(user_id int64) (int64, error)
- func GetFavoriteIdList(user_id int64) ([]int64, error)
- func GetFavoriterIdList(video_id int64) ([]int64, error)
- func GetFollowCount(follower_id int64) (int64, error)
- func GetFollowIdList(follower_id int64) ([]int64, error)
- func GetFollowerCount(user_id int64) (int64, error)
- func GetFollowerIdList(user_id int64) ([]int64, error)
- func GetFriendIdList(user_id int64) ([]int64, error)
- func GetWorkCount(user_id int64) (int64, error)
- func Init()
- func QueryFavoriteExist(user_id, video_id int64) (bool, error)
- func QueryFollowExist(user_id, follower_id int64) (bool, error)
- func QueryTotalFavoritedByAuthorID(author_id int64) (int64, error)
- func VerifyUser(userName, password string) (int64, error)
- type Comment
- type Favorites
- type Follows
- type Messages
- type User
- type Video
Constants ¶
This section is empty.
Variables ¶
var DB *gorm.DB
Functions ¶
func AddNewFavorite ¶
AddNewFavorite add favorite relation
func AddNewFollow ¶
func AddNewMessage ¶
AddNewMessage add a message and check if the id exists
func CheckCommentExist ¶
func CheckUserExistById ¶
CheckUserExistById find if user exists
func CheckVideoExistById ¶
CheckVideoExistById query if video exist
func CreateVideo ¶
func DeleteCommentById ¶
DeleteCommentById delete comment by comment id
func DeleteFavorite ¶
DeleteFavorite delete favorite relation
func DeleteFollow ¶
DeleteFollow delete follow relation in db and update redis
func GetFavoriteCount ¶
GetFavoriteCount count the favorite of video
func GetFavoriteCountByUserID ¶
GetFavoriteCountByUserID get the num of the video liked by user
func GetFavoriteIdList ¶
GetFavoriteIdList get the id list of video liked by the user
func GetFavoriterIdList ¶
GetFavoriterIdList get the id list of liker of video
func GetFollowCount ¶
GetFollowCount query the number of users following
func GetFollowIdList ¶
GetFollowIdList find user_id follow id list in db or rdb
func GetFollowerCount ¶
GetFollowerCount query the number of followers of a user
func GetFollowerIdList ¶
GetFollowerIdList get follower id list in db or rdb
func GetFriendIdList ¶
func GetWorkCount ¶
GetWorkCount get the num of video published by the user
func QueryFavoriteExist ¶
QueryFavoriteExist query the like record by video_id and user_id
func QueryFollowExist ¶
QueryFollowExist check the relation of user and follower
func QueryTotalFavoritedByAuthorID ¶
QueryTotalFavoritedByAuthorID query the like num of all the video published by the user
func VerifyUser ¶
VerifyUser verify username and password in the db
Types ¶
type Comment ¶
type Comment struct { ID int64 `json:"id"` UserId int64 `json:"user_id"` VideoId int64 `json:"video_id"` CommentText string `json:"comment_text"` CreatedAt time.Time `json:"created_at"` DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"` }
func GetCommentListByVideoID ¶
type Favorites ¶
type Follows ¶
type Follows struct { ID int64 `json:"id"` UserId int64 `json:"user_id"` FollowerId int64 `json:"follower_id"` CreatedAt time.Time `json:"create_at"` DeletedAt gorm.DeletedAt `gorm:"index" json:"delete_at"` }
Follows follower is fan of user
type Messages ¶
type Messages struct { ID int64 `json:"id"` ToUserId int64 `json:"to_user_id"` FromUserId int64 `json:"from_user_id"` Content string `json:"content"` CreatedAt time.Time `json:"created_at"` }
func GetLatestMessageByIdPair ¶
GetLatestMessageByIdPair query the last message user1 and user2 in the database
func GetMessageByIdPair ¶
GetMessageByIdPair get the chat history after a certain time
type User ¶
type User struct { ID int64 `json:"id"` UserName string `json:"user_name"` Password string `json:"password"` Avatar string `json:"avatar"` BackgroundImage string `json:"background_image"` Signature string `json:"signature"` }
func QueryUserById ¶
QueryUserById get user in the database by user id