stores

package
v0.0.1-Beta01 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package stores - NekoBlog backend server data access objects. This file is for comment storage accessing. Copyright (c) [2024], Author(s): - WhitePaper233<[email protected]> - sjyhlxysybzdhxd<[email protected]>

Package stores - NekoBlog backend server data access objects. This file is for factory of storages. Copyright (c) [2024], Author(s): - WhitePaper233<[email protected]>

Package stores - NekoBlog backend server data access objects. This file is for post storage accessing. Copyright (c) [2024], Author(s): - WhitePaper233<[email protected]> - sjyhlxysybzdhxd<[email protected]> - CBofJOU<[email protected]>

Package stores - NekoBlog backend server data access objects. This file is for user storage accessing. Copyright (c) [2024], Author(s): - WhitePaper233<[email protected]> - sjyhlxysybzdhxd<[email protected]>

Index

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 NewFactory(db *gorm.DB) *Factory

func (*Factory) NewCommentStore

func (factory *Factory) NewCommentStore() *CommentStore

NewCommentStore 返回一个新的用户存储实例。 返回:

  • *CommentStore: 返回一个指向新的用户存储实例的指针。

func (*Factory) NewPostStore

func (factory *Factory) NewPostStore() *PostStore

NewPostStore 是一个工厂方法,用于创建 PostStore 的新实例。

参数 - factory: 一个包含 gorm.DB 的 Factory 实例,用于初始化 PostStore 的数据库连接。

返回值 它初始化并返回一个 PostStore,并关联了相应的 gorm.DB。

func (*Factory) NewUserStore

func (factory *Factory) NewUserStore() *UserStore

NewUserStore 返回一个新的 UserStore 实例。

返回值:

  • *UserStore:新的 UserStore 实例。

type PostStore

type PostStore struct {
	// contains filtered or unexported fields
}

PostStore 博文信息数据库

func (*PostStore) CachePostIamge

func (store *PostStore) CachePostIamge(image []byte) (string, error)

func (*PostStore) CancelFavouritePost

func (store *PostStore) CancelFavouritePost(uid, postID int64) error

CancelFavouritePost 取消收藏博文

参数:

  • uid:用户ID
  • postID:待取消收藏博文的ID

返回值:

  • error:如果发生错误,返回相应错误信息;否则返回 nil

func (*PostStore) CancelLikePost

func (store *PostStore) CancelLikePost(uid, postID int64) error

CancelLikePost 取消点赞博文

参数:

  • uid:用户ID
  • postID:待取消点赞博文的ID

返回值:

  • error:如果发生错误,返回相应错误信息;否则返回 nil

func (*PostStore) CheckCacheImageExistence

func (store *PostStore) CheckCacheImageExistence(uuid string) (bool, error)

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

func (store *PostStore) DeletePost(postID uint64) error

DeletePost 通过博文ID删除博文的存储方法

参数: - postID uint64:待删除博文的ID

返回值: - error:如果发生错误,返回相应错误信息;否则返回 nil

func (*PostStore) FavouritePost

func (store *PostStore) FavouritePost(uid, postID int64) error

FavouritePost 收藏博文

参数:

  • uid:用户ID
  • postID:待收藏博文的ID

返回值:

  • error:如果发生错误,返回相应错误信息;否则返回 nil

func (*PostStore) GetPostInfo

func (store *PostStore) GetPostInfo(postID uint64) (models.PostInfo, error)

GetPostByUID 通过用户UID获取用户信息。

参数:

  • uid:用户ID

返回值:

  • *models.PostInfo:如果找到了相应的用户信息,则返回该用户信息,否则返回nil。
  • error:如果在获取过程中发生错误,则返回相应的错误信息,否则返回nil。

func (*PostStore) GetPostList

func (store *PostStore) GetPostList() ([]models.PostInfo, error)

GetPostList 获取适用于用户查看的帖子信息列表。

返回值: - []models.UserPostInfo: 包含适用于用户查看的帖子信息的切片。 - error: 在检索过程中遇到的任何错误,如果有的话。

func (*PostStore) GetPostListByUID

func (store *PostStore) GetPostListByUID(uid string) ([]models.PostInfo, error)

GetPostListByUID 获取适用于用户查看的帖子信息列表。

参数: - uid:用户ID

返回值: - []models.UserPostInfo: 包含适用于用户查看的帖子信息的切片。 - error: 在检索过程中遇到的任何错误,如果有的话。

func (*PostStore) GetPostUserStatus

func (store *PostStore) GetPostUserStatus(uid, postID int64) (bool, bool, error)

GetPostUserStatus 获取用户对帖子的状态

参数:

  • uid int64:用户ID
  • postID int64:帖子ID

返回值:

  • bool:用户是否点赞
  • bool:用户是否收藏
  • error:如果发生错误,返回相应错误信息;否则返回 nil

func (*PostStore) LikePost

func (store *PostStore) LikePost(uid, postID int64) error

LikePost 点赞博文

参数:

  • postID uint64:待点赞博文的ID

返回值:

  • error:如果发生错误,返回相应错误信息;否则返回 nil

func (*PostStore) ValidatePostExistence

func (store *PostStore) ValidatePostExistence(postID uint64) (bool, error)

ValidatePostExistence 用来检查是否存在Post博文

参数:postID:博文ID

返回值: - bool: 找到返回true ,找不到返回false - error: 返回的错误类型是否是post为空

type UserStore

type UserStore struct {
	// contains filtered or unexported fields
}

UserStore 用户信息数据库

func (*UserStore) BanUserToken

func (store *UserStore) BanUserToken(token string) error

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

func (store *UserStore) GetUserByUID(uid uint64) (*models.UserInfo, error)

GetUserByUID 通过用户ID获取用户信息。

参数:

  • uid:用户ID

返回值:

  • *models.UserInfo:如果找到了相应的用户信息,则返回该用户信息,否则返回nil。
  • error:如果在获取过程中发生错误,则返回相应的错误信息,否则返回nil。

func (*UserStore) GetUserByUsername

func (store *UserStore) GetUserByUsername(username string) (*models.UserInfo, error)

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

func (store *UserStore) IsUserTokenAvaliable(token string) (bool, error)

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

func (store *UserStore) SaveUserAvatarByUID(uid uint64, fileName string, data []byte) error

SaveUserAvatarByUID 保存用户头像。

参数:

  • fileName:文件名
  • data:文件数据

返回值:

  • error:如果在保存过程中发生错误,则返回相应的错误信息,否则返回nil。

func (*UserStore) UpdateUserInfoByUID

func (store *UserStore) UpdateUserInfoByUID(uid uint64, updatedProfile *models.UserInfo) error

UpdateUserInfoByUID 更新用户信息。

参数:

  • uid:用户ID
  • updatedProfile:更新后的用户信息

返回值:

  • error:如果在更新过程中发生错误,则返回相应的错误信息,否则返回nil。

func (*UserStore) UpdateUserPasswordByUsername

func (store *UserStore) UpdateUserPasswordByUsername(username string, hashedNewPassword string) error

UpdateUserPasswordByUsername 更新用户密码。

参数:

  • username:用户名
  • hashedNewPassword:经过哈希处理的新密码

返回值:

  • error:如果在更新过程中发生错误,则返回相应的错误信息,否则返回nil。

Jump to

Keyboard shortcuts

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