broker

package
v0.0.0-...-8be1489 Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_WHISPER_NUM_DAILY = 20

MAX_WHISPER_NUM_DAILY 当日单用户私信总数限制(TODO 配置化、积分兑换等)

Variables

View Source
var (
	DisablePhoneVerify bool
)

Functions

func AddFriend

func AddFriend(user *core.User, param *AddFriendReq) error

func BuyPostAttachment

func BuyPostAttachment(post *core.Post, user *core.User) error

func ChangeUserAvatar

func ChangeUserAvatar(user *core.User, avatar string) (err *errcode.Error)

func CheckPassword

func CheckPassword(password string) error

CheckPassword 密码检查

func CheckPhoneCaptcha

func CheckPhoneCaptcha(phone, captcha string) *errcode.Error

CheckPhoneCaptcha 验证手机验证码

func CheckPhoneExist

func CheckPhoneExist(uid int64, phone string) bool

CheckPhoneExist 检测手机号是否存在

func CheckPostAttachmentIsPaid

func CheckPostAttachmentIsPaid(postID, userID int64) bool

func CheckStatus

func CheckStatus(user *core.User) bool

CheckStatus 检测用户权限

func CreateAttachment

func CreateAttachment(attachment *core.Attachment) (*core.Attachment, error)

func CreatePost

func CreatePost(c *gin.Context, userID int64, param PostCreationReq) (_ *core.PostFormated, err error)

CreatePost 创建文章 TODO: 推文+推文内容需要在一个事务中添加,后续优化

func CreatePostCollection

func CreatePostCollection(postID, userID int64) (*core.PostCollection, error)

func CreatePostComment

func CreatePostComment(ctx *gin.Context, userID int64, param CommentCreationReq) (comment *core.Comment, err error)

func CreatePostCommentReply

func CreatePostCommentReply(ctx *gin.Context, commentID int64, content string, userID, atUserID int64) (*core.CommentReply, error)

func CreatePostStar

func CreatePostStar(postID, userID int64) (*core.PostStar, error)

func CreateRecharge

func CreateRecharge(userID, amount int64) (*core.WalletRecharge, error)

func CreateWhisper

func CreateWhisper(c *gin.Context, msg *core.Message) (*core.Message, error)

CreateWhisper 创建私信

func DeleteFriend

func DeleteFriend(user *core.User, param *DeleteFriendReq) error

func DeletePost

func DeletePost(user *core.User, id int64) *errcode.Error

func DeletePostCollection

func DeletePostCollection(collection *core.PostCollection) error

func DeletePostComment

func DeletePostComment(comment *core.Comment) error

func DeletePostCommentReply

func DeletePostCommentReply(reply *core.CommentReply) error

func DeletePostStar

func DeletePostStar(star *core.PostStar) error

func DeleteSearchPost

func DeleteSearchPost(post *core.Post) error

func DoLogin

func DoLogin(ctx *gin.Context, param *AuthRequest) (*core.User, error)

DoLogin 用户认证

func EncryptPasswordAndSalt

func EncryptPasswordAndSalt(password string) (string, string)

EncryptPasswordAndSalt 密码加密&生成salt

func FinishRecharge

func FinishRecharge(ctx *gin.Context, id int64, tradeNo string) error

func GetContacts

func GetContacts(user *core.User, offset int, limit int) (*core.ContactList, error)

func GetIndexPosts

func GetIndexPosts(user *core.User, offset int, limit int) (*core.IndexTweetList, error)

func GetMessages

func GetMessages(userID int64, offset, limit int) ([]*core.MessageFormated, int64, error)

func GetParamSign

func GetParamSign(param map[string]any, secretKey string) string

func GetPost

func GetPost(id int64) (*core.PostFormated, error)

func GetPostCollection

func GetPostCollection(postID, userID int64) (*core.PostCollection, error)

func GetPostComment

func GetPostComment(id int64) (*core.Comment, error)

func GetPostCommentReply

func GetPostCommentReply(id int64) (*core.CommentReply, error)

func GetPostComments

func GetPostComments(postID int64, sort string, offset, limit int) ([]*core.CommentFormated, int64, error)

func GetPostContentByID

func GetPostContentByID(id int64) (*core.PostContent, error)

func GetPostCount

func GetPostCount(conditions *core.ConditionsT) (int64, error)

func GetPostList

func GetPostList(req *PostListReq) ([]*core.Post, []*core.PostFormated, error)

func GetPostListFromSearch

func GetPostListFromSearch(user *core.User, q *core.QueryReq, offset, limit int) ([]*core.PostFormated, int64, error)

func GetPostListFromSearchByQuery

func GetPostListFromSearchByQuery(user *core.User, query string, offset, limit int) ([]*core.PostFormated, int64, error)

func GetPostStar

func GetPostStar(postID, userID int64) (*core.PostStar, error)

func GetPostTags

func GetPostTags(param *PostTagsReq) ([]*core.TagFormated, error)

func GetRandomAvatar

func GetRandomAvatar() string

func GetRechargeByID

func GetRechargeByID(id int64) (*core.WalletRecharge, error)

func GetSuggestTags

func GetSuggestTags(keyword string) ([]string, error)

GetSuggestTags 根据关键词获取标签推荐

func GetSuggestUsers

func GetSuggestUsers(keyword string) ([]string, error)

GetSuggestUsers 根据关键词获取用户推荐

func GetUnreadCount

func GetUnreadCount(userID int64) (int64, error)

func GetUserByID

func GetUserByID(id int64) (*core.User, error)

func GetUserCollections

func GetUserCollections(userID int64, offset, limit int) ([]*core.PostFormated, int64, error)

GetUserCollections 获取用户收藏列表

func GetUserInfo

func GetUserInfo(param *AuthRequest) (*core.User, error)

GetUserInfo 获取用户信息

func GetUserStars

func GetUserStars(userID int64, offset, limit int) ([]*core.PostFormated, int64, error)

GetUserStars 获取用户点赞列表

func GetUserWalletBills

func GetUserWalletBills(userID int64, offset, limit int) ([]*core.WalletStatement, int64, error)

GetUserWalletBills 获取用户账单列表

func Initialize

func Initialize()

func IsFriend

func IsFriend(userId, friendId int64) bool

func LockPost

func LockPost(id int64) error

func PushPostToSearch

func PushPostToSearch(post *core.Post)

func PushPostsToSearch

func PushPostsToSearch(c *gin.Context)

func ReadMessage

func ReadMessage(id, userID int64) error

func Register

func Register(username, password string) (*core.User, error)

Register 用户注册

func RejectFriend

func RejectFriend(user *core.User, param *RejectFriendReq) error

func RequestingFriend

func RequestingFriend(user *core.User, param *RequestingFriendReq) error

func SendPhoneCaptcha

func SendPhoneCaptcha(ctx *gin.Context, phone string) error

SendPhoneCaptcha 发送短信验证码

func StickPost

func StickPost(id int64) error

func UpdateUserInfo

func UpdateUserInfo(user *core.User) *errcode.Error

UpdateUserInfo 更新用户信息

func ValidPassword

func ValidPassword(dbPassword, password, salt string) bool

ValidPassword 检查密码是否一致

func ValidUsername

func ValidUsername(username string) error

ValidUsername 验证用户

func VisiblePost

func VisiblePost(user *core.User, postId int64, visibility core.PostVisibleT) *errcode.Error

Types

type AddFriendReq

type AddFriendReq struct {
	UserId int64 `json:"user_id" binding:"required"`
}

type AuthRequest

type AuthRequest struct {
	Username string `json:"username" form:"username" binding:"required"`
	Password string `json:"password" form:"password" binding:"required"`
}

type ChangeAvatarReq

type ChangeAvatarReq struct {
	Avatar string `json:"avatar" form:"avatar" binding:"required"`
}

type ChangeNicknameReq

type ChangeNicknameReq struct {
	Nickname string `json:"nickname" form:"nickname" binding:"required"`
}

type ChangePasswordReq

type ChangePasswordReq struct {
	Password    string `json:"password" form:"password" binding:"required"`
	OldPassword string `json:"old_password" form:"old_password" binding:"required"`
}

type ChangeUserStatusReq

type ChangeUserStatusReq struct {
	ID     int64 `json:"id" form:"id" binding:"required"`
	Status int   `json:"status" form:"status" binding:"required"`
}

type CommentCreationReq

type CommentCreationReq struct {
	PostID   int64              `json:"post_id" binding:"required"`
	Contents []*PostContentItem `json:"contents" binding:"required"`
	Users    []string           `json:"users" binding:"required"`
}

type CommentDelReq

type CommentDelReq struct {
	ID int64 `json:"id" binding:"required"`
}

type CommentReplyCreationReq

type CommentReplyCreationReq struct {
	CommentID int64  `json:"comment_id" binding:"required"`
	Content   string `json:"content" binding:"required"`
	AtUserID  int64  `json:"at_user_id"`
}

type DeleteFriendReq

type DeleteFriendReq struct {
	UserId int64 `json:"user_id"`
}

type PhoneCaptchaReq

type PhoneCaptchaReq struct {
	Phone        string `json:"phone" form:"phone" binding:"required"`
	ImgCaptcha   string `json:"img_captcha" form:"img_captcha" binding:"required"`
	ImgCaptchaID string `json:"img_captcha_id" form:"img_captcha_id" binding:"required"`
}

type PostCollectionReq

type PostCollectionReq struct {
	ID int64 `json:"id" binding:"required"`
}

type PostContentItem

type PostContentItem struct {
	Content string            `json:"content"  binding:"required"`
	Type    core.PostContentT `json:"type"  binding:"required"`
	Sort    int64             `json:"sort"  binding:"required"`
}

func (*PostContentItem) Check

func (p *PostContentItem) Check() error

Check 检查PostContentItem属性

type PostCreationReq

type PostCreationReq struct {
	Contents        []*PostContentItem `json:"contents" binding:"required"`
	Tags            []string           `json:"tags" binding:"required"`
	Users           []string           `json:"users" binding:"required"`
	AttachmentPrice int64              `json:"attachment_price"`
	Visibility      core.PostVisibleT  `json:"visibility"`
}

type PostDelReq

type PostDelReq struct {
	ID int64 `json:"id" binding:"required"`
}

type PostListReq

type PostListReq struct {
	Conditions *core.ConditionsT
	Offset     int
	Limit      int
}

type PostLockReq

type PostLockReq struct {
	ID int64 `json:"id" binding:"required"`
}

type PostStarReq

type PostStarReq struct {
	ID int64 `json:"id" binding:"required"`
}

type PostStickReq

type PostStickReq struct {
	ID int64 `json:"id" binding:"required"`
}

type PostTagsReq

type PostTagsReq struct {
	Type TagType `json:"type" form:"type" binding:"required"`
	Num  int     `json:"num" form:"num" binding:"required"`
}

type PostVisibilityReq

type PostVisibilityReq struct {
	ID         int64             `json:"id" binding:"required"`
	Visibility core.PostVisibleT `json:"visibility"`
}

type ReadMessageReq

type ReadMessageReq struct {
	ID int64 `json:"id" binding:"required"`
}

type RechargeReq

type RechargeReq struct {
	Amount int64 `json:"amount" form:"amount" binding:"required"`
}

type RegisterRequest

type RegisterRequest struct {
	Username string `json:"username" form:"username" binding:"required"`
	Password string `json:"password" form:"password" binding:"required"`
}

type RejectFriendReq

type RejectFriendReq struct {
	UserId int64 `json:"user_id" binding:"required"`
}

type ReplyDelReq

type ReplyDelReq struct {
	ID int64 `json:"id" binding:"required"`
}

type RequestingFriendReq

type RequestingFriendReq struct {
	UserId    int64  `json:"user_id" binding:"required"`
	Greetings string `json:"greetings" binding:"required"`
}

type TagType

type TagType string
const TagTypeHot TagType = "hot"
const TagTypeNew TagType = "new"

type UserPhoneBindReq

type UserPhoneBindReq struct {
	Phone   string `json:"phone" form:"phone" binding:"required"`
	Captcha string `json:"captcha" form:"captcha" binding:"required"`
}

type UserProfileResp

type UserProfileResp struct {
	ID       int64  `json:"id"`
	Nickname string `json:"nickname"`
	Username string `json:"username"`
	Status   int    `json:"status"`
	Avatar   string `json:"avatar"`
	IsAdmin  bool   `json:"is_admin"`
	IsFriend bool   `json:"is_friend"`
}

func GetUserByUsername

func GetUserByUsername(user *core.User, username string) (*UserProfileResp, error)

type WhisperReq

type WhisperReq struct {
	UserID  int64  `json:"user_id" binding:"required"`
	Content string `json:"content" binding:"required"`
}

Jump to

Keyboard shortcuts

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