Documentation
¶
Overview ¶
Package stores - NekoBlog backend server data access objects. This file is for comment storage accessing. Copyright (c) [2024], Author(s): - WhitePaper233<baizhiwp@gmail.com> - sjyhlxysybzdhxd<2023122308@jou.edu.cn>
Package stores - NekoBlog backend server data access objects. This file is for factory of storages. Copyright (c) [2024], Author(s): - WhitePaper233<baizhiwp@gmail.com>
Package stores - NekoBlog backend server data access objects. This file is for post storage accessing. Copyright (c) [2024], Author(s): - WhitePaper233<baizhiwp@gmail.com> - sjyhlxysybzdhxd<2023122308@jou.edu.cn> - CBofJOU<2023122312@jou.edu.cn>
Package stores - NekoBlog backend server data access objects. This file is for user storage accessing. Copyright (c) [2024], Author(s): - WhitePaper233<baizhiwp@gmail.com> - sjyhlxysybzdhxd<2023122308@jou.edu.cn>
Index ¶
- type CommentStore
- func (store *CommentStore) CancelDislikeComment(uid, commentID uint64) error
- func (store *CommentStore) CancelLikeComment(uid, commentID uint64) error
- func (store *CommentStore) CreateComment(uid uint64, username string, postID uint64, content string) (uint64, error)
- func (store *CommentStore) DeleteComment(commentID uint64) error
- func (store *CommentStore) DislikeComment(uid, commentID uint64) error
- func (store *CommentStore) GetCommentInfo(commentID uint64) (models.CommentInfo, error)
- func (store *CommentStore) GetCommentList(postID uint64) ([]models.CommentInfo, error)
- func (store *CommentStore) GetCommentUserStatus(uid, commentID uint64) (bool, bool, error)
- func (store *CommentStore) LikeComment(uid, commentID uint64) error
- func (store *CommentStore) UpdateComment(commentID uint64, content string) error
- func (store *CommentStore) ValidateCommentExistence(commentID uint64) (bool, error)
- type Factory
- type PostStore
- func (store *PostStore) CachePostIamge(image []byte) (string, error)
- func (store *PostStore) CancelFavouritePost(uid, postID int64) error
- func (store *PostStore) CancelLikePost(uid, postID int64) error
- func (store *PostStore) CheckCacheImageExistence(uuid string) (bool, error)
- func (store *PostStore) CreatePost(uid uint64, ipAddr string, postReqData types.PostCreateBody) (models.PostInfo, error)
- func (store *PostStore) DeletePost(postID uint64) error
- func (store *PostStore) FavouritePost(uid, postID int64) error
- func (store *PostStore) GetPostInfo(postID uint64) (models.PostInfo, error)
- func (store *PostStore) GetPostList() ([]models.PostInfo, error)
- func (store *PostStore) GetPostListByUID(uid string) ([]models.PostInfo, error)
- func (store *PostStore) GetPostUserStatus(uid, postID int64) (bool, bool, error)
- func (store *PostStore) LikePost(uid, postID int64) error
- func (store *PostStore) ValidatePostExistence(postID uint64) (bool, error)
- type UserStore
- func (store *UserStore) BanUserToken(token string) error
- func (store *UserStore) CreateUserAvaliableToken(token string, claims *types.BearerTokenClaims) error
- func (store *UserStore) CreateUserLoginLog(userLoginLogInfo *models.UserLoginLog) error
- func (store *UserStore) GetUserAuthInfoByUsername(username string) (*models.UserAuthInfo, error)
- func (store *UserStore) GetUserAvaliableTokensByUsername(username string) ([]models.UserAvaliableToken, error)
- func (store *UserStore) GetUserByUID(uid uint64) (*models.UserInfo, error)
- func (store *UserStore) GetUserByUsername(username string) (*models.UserInfo, error)
- func (store *UserStore) GetUserFavoriteRecord(uid string) (pq.Int64Array, error)
- func (store *UserStore) GetUserLikedRecord(uid string) (pq.Int64Array, error)
- func (store *UserStore) IsUserTokenAvaliable(token string) (bool, error)
- func (store *UserStore) RegisterUserByUsername(username string, salt string, hashedPassword string) error
- func (store *UserStore) SaveUserAvatarByUID(uid uint64, fileName string, data []byte) error
- func (store *UserStore) UpdateUserInfoByUID(uid uint64, updatedProfile *models.UserInfo) error
- func (store *UserStore) UpdateUserPasswordByUsername(username string, hashedNewPassword string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommentStore ¶
type CommentStore struct {
// contains filtered or unexported fields
}
Comment 评论信息数据库
func (*CommentStore) CancelDislikeComment ¶
func (store *CommentStore) CancelDislikeComment(uid, commentID uint64) error
CancelDislikeComment 取消点踩评论
参数:
- commentID:评论ID
- uid:用户ID
返回值:
- error:返回取消点踩处理的成功与否
func (*CommentStore) CancelLikeComment ¶
func (store *CommentStore) CancelLikeComment(uid, commentID uint64) error
CancelLikeComment 取消点赞评论
参数:
- commentID:评论ID
- uid:用户ID
返回值:
- error:返回取消点赞处理的成功与否
func (*CommentStore) CreateComment ¶
func (store *CommentStore) CreateComment(uid uint64, username string, postID uint64, content string) (uint64, error)
NewCommentStore 存储comment
参数 :- uid:用户id,- username: 用户名,- postID: 博文id,- content: 博文内容
返回:
-error 正确返回nil
func (*CommentStore) DeleteComment ¶
func (store *CommentStore) DeleteComment(commentID uint64) error
DeleteComment 删除评论
参数:
- commentID:评论ID
返回值:
- error:返回删除处理的成功与否
func (*CommentStore) DislikeComment ¶
func (store *CommentStore) DislikeComment(uid, commentID uint64) error
DislikeComment 点踩评论
参数:
- commentID:评论ID
- uid:用户ID
返回值:
- error:返回点踩处理的成功与否
func (*CommentStore) GetCommentInfo ¶
func (store *CommentStore) GetCommentInfo(commentID uint64) (models.CommentInfo, error)
GetCommentInfo 获取评论信息
参数:
- commentID:评论ID
返回值:
- models.CommentInfo:成功返回评论信息
- error:失败返回error
func (*CommentStore) GetCommentList ¶
func (store *CommentStore) GetCommentList(postID uint64) ([]models.CommentInfo, error)
GetCommentList 获取评论列表
返回值:
- 成功则返回评论列表
- 失败返回nil
func (*CommentStore) GetCommentUserStatus ¶
func (store *CommentStore) GetCommentUserStatus(uid, commentID uint64) (bool, bool, error)
GetCommentUserStatus 获取评论用户状态
参数:
- commentID:评论ID
- uid:用户ID
返回值:
- bool:返回用户状态
func (*CommentStore) LikeComment ¶
func (store *CommentStore) LikeComment(uid, commentID uint64) error
LikeComment 点赞评论
参数:
- commentID:评论ID
- uid:用户ID
返回值:
- error:返回点赞处理的成功与否
func (*CommentStore) UpdateComment ¶
func (store *CommentStore) UpdateComment(commentID uint64, content string) error
UpdateComment 修改评论
参数: - commentID: 评论ID - content: 修改内容
返回值:
- error:如果评论存在返回true,不存在判断具体的错误类型返回false
func (*CommentStore) ValidateCommentExistence ¶
func (store *CommentStore) ValidateCommentExistence(commentID uint64) (bool, error)
ValidateCommentExistence 判断评论是否存在 参数: - commentID: 评论ID
返回值:
- error:如果评论存在返回true,不存在判断具体的错误类型返回false
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
func NewFactory ¶
func (*Factory) NewCommentStore ¶
func (factory *Factory) NewCommentStore() *CommentStore
NewCommentStore 返回一个新的用户存储实例。 返回:
- *CommentStore: 返回一个指向新的用户存储实例的指针。
func (*Factory) NewPostStore ¶
NewPostStore 是一个工厂方法,用于创建 PostStore 的新实例。
参数 - factory: 一个包含 gorm.DB 的 Factory 实例,用于初始化 PostStore 的数据库连接。
返回值 它初始化并返回一个 PostStore,并关联了相应的 gorm.DB。
type PostStore ¶
type PostStore struct {
// contains filtered or unexported fields
}
PostStore 博文信息数据库
func (*PostStore) CachePostIamge ¶
func (*PostStore) CancelFavouritePost ¶
CancelFavouritePost 取消收藏博文
参数:
- uid:用户ID
- postID:待取消收藏博文的ID
返回值:
- error:如果发生错误,返回相应错误信息;否则返回 nil
func (*PostStore) CancelLikePost ¶
CancelLikePost 取消点赞博文
参数:
- uid:用户ID
- postID:待取消点赞博文的ID
返回值:
- error:如果发生错误,返回相应错误信息;否则返回 nil
func (*PostStore) CheckCacheImageExistence ¶
func (*PostStore) CreatePost ¶
func (store *PostStore) CreatePost(uid uint64, ipAddr string, postReqData types.PostCreateBody) (models.PostInfo, error)
CreatePost 根据用户提交的帖子信息创建帖子。
参数:
- userID:用户ID,用于关联帖子与用户。
- ipAddr:IP地址
- postInfo:帖子信息,包含标题、内容等。
- images:帖子图片
返回值:
- error:如果在创建过程中发生错误,则返回相应的错误信息,否则返回nil。
func (*PostStore) DeletePost ¶
DeletePost 通过博文ID删除博文的存储方法
参数: - postID uint64:待删除博文的ID
返回值: - error:如果发生错误,返回相应错误信息;否则返回 nil
func (*PostStore) FavouritePost ¶
FavouritePost 收藏博文
参数:
- uid:用户ID
- postID:待收藏博文的ID
返回值:
- error:如果发生错误,返回相应错误信息;否则返回 nil
func (*PostStore) GetPostInfo ¶
GetPostByUID 通过用户UID获取用户信息。
参数:
- uid:用户ID
返回值:
- *models.PostInfo:如果找到了相应的用户信息,则返回该用户信息,否则返回nil。
- error:如果在获取过程中发生错误,则返回相应的错误信息,否则返回nil。
func (*PostStore) GetPostList ¶
GetPostList 获取适用于用户查看的帖子信息列表。
返回值: - []models.UserPostInfo: 包含适用于用户查看的帖子信息的切片。 - error: 在检索过程中遇到的任何错误,如果有的话。
func (*PostStore) GetPostListByUID ¶
GetPostListByUID 获取适用于用户查看的帖子信息列表。
参数: - uid:用户ID
返回值: - []models.UserPostInfo: 包含适用于用户查看的帖子信息的切片。 - error: 在检索过程中遇到的任何错误,如果有的话。
func (*PostStore) GetPostUserStatus ¶
GetPostUserStatus 获取用户对帖子的状态
参数:
- uid int64:用户ID
- postID int64:帖子ID
返回值:
- bool:用户是否点赞
- bool:用户是否收藏
- error:如果发生错误,返回相应错误信息;否则返回 nil
type UserStore ¶
type UserStore struct {
// contains filtered or unexported fields
}
UserStore 用户信息数据库
func (*UserStore) BanUserToken ¶
BanUserToken 将 Token 禁用。
参数:
- token:Token
返回值:
- error:如果在禁用过程中发生错误,则返回相应的错误信息,否则返回nil。
func (*UserStore) CreateUserAvaliableToken ¶
func (store *UserStore) CreateUserAvaliableToken(token string, claims *types.BearerTokenClaims) error
CreateUserAvaliableToken 创建一个可用的 Token。
参数:
- token:Token
- claims:Token 的声明
返回值:
- error:如果在创建过程中发生错误,则返回相应的错误信息,否则返回nil。
func (*UserStore) CreateUserLoginLog ¶
func (store *UserStore) CreateUserLoginLog(userLoginLogInfo *models.UserLoginLog) error
InsertUserLoginLog 插入用户登录日志。
参数:
- userLoginLogInfo:用户登录日志信息
返回值:
- error:如果在插入过程中发生错误,则返回相应的错误信息,否则返回nil。
func (*UserStore) GetUserAuthInfoByUsername ¶
func (store *UserStore) GetUserAuthInfoByUsername(username string) (*models.UserAuthInfo, error)
GetUserAuthInfoByUsername 通过用户名获取用户的认证信息。
参数:
- username:用户名
返回值:
- *models.UserAuthInfo:如果找到了相应的用户认证信息,则返回该用户认证信息,否则返回nil。
- error:如果在获取过程中发生错误,则返回相应的错误信息,否则返回nil。
func (*UserStore) GetUserAvaliableTokensByUsername ¶
func (store *UserStore) GetUserAvaliableTokensByUsername(username string) ([]models.UserAvaliableToken, error)
GetUserAvaliableTokensByUsername 获取用户可用的 Token。
参数:
- username:用户名
返回值:
- []models.UserAvaliableToken:用户可用的 Token。
- error:如果在获取过程中发生错误,则返回相应的错误信息,否则返回nil。
func (*UserStore) GetUserByUID ¶
GetUserByUID 通过用户ID获取用户信息。
参数:
- uid:用户ID
返回值:
- *models.UserInfo:如果找到了相应的用户信息,则返回该用户信息,否则返回nil。
- error:如果在获取过程中发生错误,则返回相应的错误信息,否则返回nil。
func (*UserStore) GetUserByUsername ¶
GetUserByUsername 通过用户名获取用户信息。
参数:
- username:用户名
返回值:
- *models.UserInfo:如果找到了相应的用户信息,则返回该用户信息,否则返回nil。
- error:如果在获取过程中发生错误,则返回相应的错误信息,否则返回nil。
func (*UserStore) GetUserFavoriteRecord ¶
func (store *UserStore) GetUserFavoriteRecord(uid string) (pq.Int64Array, error)
GetUserFavoriteRecord 获取用户收藏记录。
参数:
- uid:用户ID
返回值:
- pq.Int64Array:用户收藏记录。
func (*UserStore) GetUserLikedRecord ¶
func (store *UserStore) GetUserLikedRecord(uid string) (pq.Int64Array, error)
GetUserLikedRecord 获取用户点赞记录。
参数:
- uid:用户ID
返回值:
- pq.Int64Array:用户点赞记录。
func (*UserStore) IsUserTokenAvaliable ¶
IsUserTokenAvaliable 检查 Token 是否可用。
参数:
- token:Token
返回值:
- bool:如果 Token 可用,则返回 true,否则返回 false。
- error:如果在检查过程中发生错误,则返回相应的错误信息,否则返回nil。
func (*UserStore) RegisterUserByUsername ¶
func (store *UserStore) RegisterUserByUsername(username string, salt string, hashedPassword string) error
RegisterUserByUsername 注册用户将提供的用户名、盐和哈希密码注册到数据库中。
参数:
- username:用户名
- salt:盐值
- hashedPassword:哈希密码
返回值:
- error:如果在注册过程中发生错误,则返回相应的错误信息,否则返回nil。
func (*UserStore) SaveUserAvatarByUID ¶
SaveUserAvatarByUID 保存用户头像。
参数:
- fileName:文件名
- data:文件数据
返回值:
- error:如果在保存过程中发生错误,则返回相应的错误信息,否则返回nil。
func (*UserStore) UpdateUserInfoByUID ¶
UpdateUserInfoByUID 更新用户信息。
参数:
- uid:用户ID
- updatedProfile:更新后的用户信息
返回值:
- error:如果在更新过程中发生错误,则返回相应的错误信息,否则返回nil。