Documentation ¶
Index ¶
- Constants
- Variables
- func AddFriendInviteHandler(ctx *gin.Context)
- func AddGroupMemberHandler(ctx *gin.Context)
- func AuthLoginHandler(ctx *gin.Context)
- func AuthLogoutHandler(c *gin.Context)
- func AuthRegisterHandler(ctx *gin.Context)
- func CORSMiddleware() gin.HandlerFunc
- func CheckAuthMiddleware() gin.HandlerFunc
- func CreateGroupHandler(ctx *gin.Context)
- func DeleteChatMessageHandler(ctx *gin.Context)
- func FindFriendHandler(ctx *gin.Context)
- func GetCaptchaHandler(ctx *gin.Context)
- func GetLastChatMessagesHandler(ctx *gin.Context)
- func GetProfileInfoHandler(c *gin.Context)
- func HTML(c *gin.Context, name string, obj ...any)
- func InitCaptcha()
- func InitRouter() *gin.Engine
- func InitSubscribe()
- func JSON(ctx *gin.Context, obj ...any)
- func JSONError(ctx *gin.Context, errorCode int, errorMsg string, obj ...any)
- func JSONP(ctx *gin.Context, obj ...any)
- func JSONPError(ctx *gin.Context, errorCode int, errorMsg string, obj ...any)
- func JoinGroupHandler(ctx *gin.Context)
- func LeaveGroupHandler(ctx *gin.Context)
- func LoginUserFromContext(ctx *gin.Context) *database.User
- func MessageInvalidFormat(val string) string
- func RateLimitMiddleware(limiter *goutils.Limiter) gin.HandlerFunc
- func RecoverMiddleware() gin.HandlerFunc
- func RemoveGroupMemberHandler(ctx *gin.Context)
- func RequestLogMiddleware() gin.HandlerFunc
- func RollbackChatMessageHandler(ctx *gin.Context)
- func SendChatMessageHandler(ctx *gin.Context)
- func SubscribeChatMessageHandler(ctx context.Context, payload *pubsub.Payload)
- func SubscribeFriendInviteHandler(ctx context.Context, payload *pubsub.Payload)
- func UpdateFriendHandle(ctx *gin.Context)
- func UpdateFriendInviteHandler(ctx *gin.Context)
- func UpdateGroupHandler(ctx *gin.Context)
- func UpdateGroupMemberHandler(ctx *gin.Context)
- func WebsocketHandler(ctx *gin.Context)
- func WebsocketMiddleware() gin.HandlerFunc
- type AddFriendInviteRequest
- type AddGroupMemberRequest
- type AddGroupMemberResponse
- type AuthLoginRequest
- type AuthLoginResponse
- type AuthRegisterRequest
- type AuthRegisterResponse
- type Captcha
- type ChatMessage
- type ChatMessageBody
- type CreateGroupRequest
- type CreateGroupResponse
- type FindFriendRequest
- type GetCaptchaRequest
- type GetCaptchaResponse
- type GetLastChatMessagesRequest
- type JoinGroupRequest
- type LeaveGroupRequest
- type ProfileInfoResponse
- type RedisCaptchaStore
- type RemoveGroupMemberRequest
- type RemoveGroupMemberResponse
- type Response
- type RollbackChatMessageRequest
- type SendChatMessageRequest
- type UpdateFriendInviteRequest
- type UpdateFriendRequest
- type UpdateGroupMemberRequest
- type UpdateGroupRequest
- type User
- type UserClaims
- type WebsocketMessageRequest
- type WebsocketMessageResponse
Constants ¶
const ( // MaxLoginFailTimes 最多登录失败次数 MaxLoginFailTimes = 5 // NeedCaptchaLoginFailTimes 需要验证码的失败登录次数 NeedCaptchaLoginFailTimes = 3 )
const ( LOGIN_USER_CONTEXT_KEY = "LOGIN_USER" LOGIN_USER_ID_CONTEXT_KEY = "LOGIN_USER_ID" REQUEST_LOGGER_CONTEXT_KEY = "REQUEST_LOGGER" REQUEST_ID_CONTEXT_KEY = "REQUEST_ID" )
const ( StatusOK = 1 StatusError = 2 )
Variables ¶
var ( MessageInternalServerError = "内部服务错误" MessageInvalidParams = "参数无效" MessageNotFound = "找不到记录" MessageInvalidGroupID = "'group_id'无效" MessageInvalidUserID = "'user_id'无效" MessageInvalidUserIDs = "'user_ids'无效" MessageInvalidUsername = "'username'无效" MessageInvalidNickname = "'nickname'无效" MessageInvalidPassword = "'password'无效" MessageInvalidSessionType = "'session_type'无效" MessageInvalidType = "'type'无效" MessageInvalidTargetID = "'target_id'无效" MessageInvalidLastMessageID = "'last_message_id'无效" MessageInvalidLimit = "'limit'无效" MessageChatYourself = "不可与自己聊天" MessageNotFriends = "您与对方不是好友关系" MessageAlreadyFriends = "你们已经是好友关系" MessageBlockYou = "对方已将您拉黑" MessageInvalidTimeFormat = "时间格式无效" MessageAccountExists = "账户已存在" MessageAccountNotExists = "账户不存在" MessageAccountDisable = "账户已停用" MessageAccountDeleted = "账户已删除" MessageTargetNotExists = "对方不存在" MessageTargetDisable = "对方已停用" MessageTargetDeleted = "对方已删除" MessageIncorrectUsernameOrPassword = "用户名或密码错误" MessageConfirmPasswordWrong = "确认密码错误" MessageIncorrectUsernameOrPasswordMoreTimes = "用户或密码错误超过限制" MessageEmptyCaptchaID = "验证码ID未填写" MessageEmptyCaptcha = "验证码未填写" MessageInvalidCaptcha = "验证码无效" MessageForbidden = "没有权限" MessageRollbackChatMessageFailure = "撤回聊天消息失败" )
Functions ¶
func AddFriendInviteHandler ¶
AddFriendInviteHandler @Summary 邀请加为好友 @Tags 朋友 @Accept json @Produce json @Param jsonRaw body AddFriendInviteRequest true "请求JSON数据体" @Security APIKeyHeader @Success 200 {object} Response @Failure 400 {object} Response @Failure 404 {object} Response @Failure 500 {object} Response @Router /v1/friend/invite/add [post]
func AddGroupMemberHandler ¶
AddGroupMemberHandler @Summary 增加群成员 @Tags 群组 @Accept json @Produce json @Param jsonRaw body AddGroupMemberRequest true "请求JSON数据体" @Security APIKeyHeader @Success 200 {object} Response{data=AddGroupMemberResponse} @Failure 400 {object} Response @Failure 404 {object} Response @Failure 500 {object} Response @Router /v1/group/member/add [post]
func AuthLoginHandler ¶
AuthLoginHandler @Summary 登录 @Tags 认证 @Accept json @Produce json @Param jsonRaw body AuthLoginRequest true "请求JSON数据体" @Success 200 {object} Response{data=AuthLoginResponse} @Failure 400 {object} Response @Failure 404 {object} Response @Failure 500 {object} Response @Router /v1/auth/login [post]
func AuthRegisterHandler ¶
AuthRegisterHandler @Summary 注册 @Tags 认证 @Accept json @Produce json @Param jsonRaw body AuthRegisterRequest true "请求JSON数据体" @Success 200 {object} Response{data=AuthRegisterResponse} @Failure 400 {object} Response @Failure 404 {object} Response @Failure 500 {object} Response @Router /v1/auth/register [post]
func CheckAuthMiddleware ¶
func CheckAuthMiddleware() gin.HandlerFunc
CheckAuthMiddleware 检验认证中间件 一般http请求使用的认证中间件,websocket使用 WebsocketMiddleware 方法进行独立鉴权及日志收集
func CreateGroupHandler ¶
CreateGroupHandler @Summary 创建群 @Tags 群组 @Accept json @Produce json @Param jsonRaw body CreateGroupRequest true "请求JSON数据体" @Security APIKeyHeader @Success 200 {object} Response{data=CreateGroupResponse} @Failure 400 {object} Response @Failure 404 {object} Response @Failure 500 {object} Response @Router /v1/group/create [post]
func FindFriendHandler ¶
FindFriendHandler @Summary 查找好友 @Tags 朋友 @Accept json @Produce json @Param user_id query int false "用户ID; 'user_id'跟'nickname'必选一个" @Param nickname query int false "用户昵称; 'user_id'跟'nickname'必选一个" @Param start_id query int false "用于搜索下一批用户的起始ID;是上次返回结果中最大的用户ID" @Security APIKeyQuery @Success 200 {object} Response{data=[]User} @Failure 400 {object} Response @Failure 404 {object} Response @Failure 500 {object} Response @Router /v1/friend/find [get]
func GetCaptchaHandler ¶ added in v1.0.4
GetCaptchaHandler @Summary 登录 @Tags 认证 @Accept json @Produce json @Param type query string true "capthca类型;audio,string,math,chinese,digit" @Success 200 {object} Response{data=GetCaptchaResponse} @Failure 400 {object} Response @Failure 404 {object} Response @Failure 500 {object} Response @Router /v1/auth/captcha [get]
func GetLastChatMessagesHandler ¶ added in v1.0.3
GetLastChatMessagesHandler @Summary 获取最近的聊天消息 @Tags 聊天 @Accept json @Produce json @Param target_id query int true "目标ID; 朋友ID/群ID/世界频道ID" @Param session_type query int true "会话类型; 1-私人会话;2-群聊会话;99-世界频道会话" @Security APIKeyQuery @Success 200 {object} Response{data=[]ChatMessage} @Failure 400 {object} Response @Failure 404 {object} Response @Failure 500 {object} Response @Router /v1/chat/message/last [get]
func GetProfileInfoHandler ¶
GetProfileInfoHandler 获取个人画像信息
func InitRouter ¶ added in v1.0.4
func JSONPError ¶
JSONPError 返回JSONP格式的错误数据
func JoinGroupHandler ¶
JoinGroupHandler @Summary 加入群 @Tags 群组 @Accept json @Produce json @Param jsonRaw body JoinGroupRequest true "请求JSON数据体" @Security APIKeyHeader @Success 200 {object} Response @Failure 400 {object} Response @Failure 404 {object} Response @Failure 500 {object} Response @Router /v1/group/join [post]
func LeaveGroupHandler ¶
LeaveGroupHandler @Summary 离开群 @Tags 群组 @Accept json @Produce json @Param jsonRaw body LeaveGroupRequest true "请求JSON数据体" @Security APIKeyHeader @Success 200 {object} Response @Failure 400 {object} Response @Failure 404 {object} Response @Failure 500 {object} Response @Router /v1/group/leave [post]
func LoginUserFromContext ¶
LoginUserFromContext 从上下文中获取当前登录的的用户信息 如果通过 checkAuth 方法鉴权过的,下文的 *gin.Context 必能找到用户信息
func MessageInvalidFormat ¶
MessageInvalidFormat 格式化参数无效错误
func RateLimitMiddleware ¶ added in v1.0.9
func RateLimitMiddleware(limiter *goutils.Limiter) gin.HandlerFunc
RateLimitMiddleware 请求速率限定中间件
func RemoveGroupMemberHandler ¶
RemoveGroupMemberHandler @Summary 移除群成员 @Tags 群组 @Accept json @Produce json @Param jsonRaw body RemoveGroupMemberRequest true "请求JSON数据体" @Security APIKeyHeader @Success 200 {object} Response{data=RemoveGroupMemberResponse} @Failure 400 {object} Response @Failure 404 {object} Response @Failure 500 {object} Response @Router /v1/group/member/remove [post]
func RequestLogMiddleware ¶
func RequestLogMiddleware() gin.HandlerFunc
RequestLogMiddleware 请求日志中间件
func RollbackChatMessageHandler ¶
RollbackChatMessageHandler 撤回聊天消息处理方法 @Summary 撤回聊天消息处理方法 @Tags 聊天 @Accept json @Produce json @Param jsonRaw body RollbackChatMessageRequest true "请求JSON数据体" @Security APIKeyQuery @Success 200 {object} Response @Failure 400 {object} Response @Failure 404 {object} Response @Failure 500 {object} Response @Router /v1/chat/message/rollback [post]
func SendChatMessageHandler ¶
SendChatMessageHandler @Summary 发送聊天消息 @Tags 聊天 @Accept json @Produce json @Param jsonRaw body SendChatMessageRequest true "请求JSON数据体" @Security APIKeyHeader @Success 200 {object} Response{data=[]ChatMessage} @Failure 400 {object} Response @Failure 404 {object} Response @Failure 500 {object} Response @Router /v1/chat/message/send [post]
func SubscribeChatMessageHandler ¶
SubscribeChatMessageHandler 接收聊天消息
func SubscribeFriendInviteHandler ¶
SubscribeFriendInviteHandler 订阅好友邀请控制器
func UpdateFriendHandle ¶
UpdateFriendHandle @Summary 更新朋友信息 // 可进行删除好友,拉黑好友 @Tags 朋友 @Accept json @Produce json @Param jsonRaw body UpdateFriendInviteRequest true "请求JSON数据体" @Security APIKeyHeader @Success 200 {object} Response @Failure 400 {object} Response @Failure 404 {object} Response @Failure 500 {object} Response @Router /v1/friend/update [post]
func UpdateFriendInviteHandler ¶
UpdateFriendInviteHandler @Summary 处理好友邀请 @Tags 朋友 @Accept json @Produce json @Param jsonRaw body UpdateFriendInviteRequest true "请求JSON数据体" @Security APIKeyHeader @Success 200 {object} Response @Failure 400 {object} Response @Failure 404 {object} Response @Failure 500 {object} Response @Router /v1/friend/invite/update [post]
func UpdateGroupHandler ¶
UpdateGroupHandler @Summary 更新群信息 @Tags 群组 @Accept json @Produce json @Param jsonRaw body UpdateGroupRequest true "请求JSON数据体" @Security APIKeyHeader @Success 200 {object} Response{} @Failure 400 {object} Response @Failure 404 {object} Response @Failure 500 {object} Response @Router /v1/group/update [post]
func UpdateGroupMemberHandler ¶
UpdateGroupMemberHandler @Summary 更新群成员 @Tags 群组 @Accept json @Produce json @Param jsonRaw body UpdateGroupMemberRequest true "请求JSON数据体" @Security APIKeyHeader @Success 200 {object} Response{} @Failure 400 {object} Response @Failure 404 {object} Response @Failure 500 {object} Response @Router /v1/group/member/update [post]
func WebsocketHandler ¶
WebsocketHandler websocket连接处理方法 `/api/ws`
func WebsocketMiddleware ¶
func WebsocketMiddleware() gin.HandlerFunc
WebsocketMiddleware websocket用的中间件 因为websocket连接会导致协程阻塞,无法进行到下一步,导致日志也一并堵塞 需要在ctx.Next() 之前调用 日志的send或者msg
Types ¶
type AddFriendInviteRequest ¶
type AddFriendInviteRequest struct { // UserID 目标用户ID UserID int64 `json:"user_id" binding:"required" min:"1" example:"1"` // Note 添加好友时,给对方看的备注 Note string `json:"note" example:"你好,我是Jerbe"` }
AddFriendInviteRequest 邀请用户成为好友操作请求参数 @Description 邀请用户成为好友操作请求参数
type AddGroupMemberRequest ¶
type AddGroupMemberRequest struct { // GroupID 群ID GroupID int64 `json:"group_id" binding:"required" example:"1098"` // UserIDs 被邀请加入的用户ID列表 UserIDs []int64 `json:"user_ids" binding:"required" example:"1,2,3,4"` }
AddGroupMemberRequest 增加群成员请求参数 @Description 增加群成员请求参数
type AddGroupMemberResponse ¶
type AddGroupMemberResponse struct { // Count 成功加入群的成员数量 Count int64 `json:"count" binding:"required" example:"22"` }
AddGroupMemberResponse 增加群成员返回参数 @Description 增加群返回请求参数
type AuthLoginRequest ¶
type AuthLoginRequest struct { // Username 账户名 Username string `json:"username" binding:"required" example:"admin"` // Password 密码 Password string `json:"password" binding:"required" example:"password"` // Captcha 验证码;当登录错误超过次数时,必须填 Captcha string `json:"captcha"` // CaptchaID 验证码ID; 当登录错误超过次数时,必须填; 通过调用 /api/v1/auth/captcha 获得 CaptchaID string `json:"captcha_id"` }
AuthLoginRequest @Description 用户登陆请求参数
type AuthLoginResponse ¶
type AuthLoginResponse struct { // Token 认证Token Token *string `` /* 154-byte string literal not displayed */ // ExpiresAt 到期时间 ExpiresAt *int64 `json:"expires_at,omitempty" example:"1725249106"` // FailTimes 累计失败次数 FailTimes *int64 `json:"fail_times,omitempty"` // NeedCaptcha 是否需要验证码 NeedCaptcha *bool `json:"need_captcha,omitempty"` }
AuthLoginResponse 用户登陆返回数据 @Description 用户登陆返回参数
type AuthRegisterRequest ¶
type AuthRegisterRequest struct { // Username 账户名 Username string `json:"username" binding:"required" example:"admin"` // Password 密码 Password string `json:"password" binding:"required" minLength:"8" example:"password"` // ConfirmPassword 确认密码 ConfirmPassword string `json:"confirm_password" binding:"required" minLength:"8" example:"password"` // BirthDate 生辰八字 BirthDate string `json:"birth_date,omitempty" minLength:"8" example:"2016-01-02"` // Nickname 昵称 Nickname string `json:"nickname,omitempty" minLength:"2" example:"昵称"` // Captcha 验证码 Captcha string `json:"captcha" binding:"required" ` // CaptchaID 验证码ID, 通过调用 /api/v1/auth/captcha 获得 CaptchaID string `json:"captcha_id" binding:"required" ` }
AuthRegisterRequest @Description 用户注册请求参数
type AuthRegisterResponse ¶
type AuthRegisterResponse struct { // UserID 用户ID UserID *int64 `json:"user_id" binding:"required" example:"10086"` // Username 账户名 Username string `json:"username" binding:"required" example:"admin"` // Nickname 昵称 Nickname string `json:"nickname" binding:"required" example:"the king"` // BirthDate 生辰八字 BirthDate string `form:"birth_date" binding:"required" example:"2016-01-02"` // Avatar 头像地址 Avatar string `json:"avatar" binding:"required" example:"https://www.baidu.com/logo.png"` }
AuthRegisterResponse @Description 用户注册返回数据
type Captcha ¶ added in v1.0.4
type Captcha struct { Store base64Captcha.Store DriverAudio base64Captcha.Driver DriverString base64Captcha.Driver DriverChinese base64Captcha.Driver DriverLanguage base64Captcha.Driver DriverMath base64Captcha.Driver DriverDigit base64Captcha.Driver }
Captcha 验证码组件
type ChatMessage ¶ added in v1.0.3
type ChatMessage struct { // ID 消息ID ID string `json:"id" example:"9d7a3bcd72"` // ActionID 行为ID,由前端生成 ActionID string `json:"action_id,omitempty" example:"8d7a3bcd72"` // SessionType 会话类型; 1:私聊, 2:群聊 SessionType int `json:"session_type" binding:"required" enums:"1,2" example:"1"` // Type 消息类型; 1-纯文本,2-图片,3-语音,4-视频, 5-位置 Type int `json:"type" enums:"1,2,3,4,5" binding:"required" example:"1"` // SenderID 发送方ID SenderID int64 `json:"sender_id" example:"1234456"` // ReceiverID 接收方ID ReceiverID int64 `json:"receiver_id" example:"1"` // MessageID 消息ID MessageID int64 `json:"message_id" example:"123"` // CreatedAt 创建 CreatedAt int64 `json:"created_at"example:"12345678901234"` // Body 消息体; Body ChatMessageBody `json:"body" binding:"required"` }
ChatMessage 消息体 @Description 消息体
func (*ChatMessage) MarshalBinary ¶ added in v1.0.3
func (cm *ChatMessage) MarshalBinary() ([]byte, error)
func (*ChatMessage) UnmarshalBinary ¶ added in v1.0.3
func (cm *ChatMessage) UnmarshalBinary(data []byte) error
type ChatMessageBody ¶
type ChatMessageBody struct { // 文本信息。适用消息类型: 1 Text string `json:"text,omitempty" example:"这是一条聊天文案"` // 来源地址。通用字段,适用消息类型: 2,3,4 Src string `json:"src,omitempty" example:"https://www.baidu.com/logo.png"` // 文件格式。适用消息类型: 2,3,4 Format string `json:"format,omitempty" example:"jpeg"` // 文件大小。适用消息类型: 2,3,4 Size string `json:"size,omitempty" example:"1234567890"` // 位置信息-经度。 适用消息类型: 5 Longitude string `json:"longitude,omitempty" example:"0.213124212313"` // 位置信息-纬度。 适用消息类型: 5 Latitude string `json:"latitude,omitempty" example:"0.913124212313"` // 位置信息-地图缩放级别。 适用消息类型: 5 Scale float64 `json:"scale,omitempty" example:"0.22"` // 位置信息标签。适用消息类型: 5 LocationLabel string `json:"location_label,omitempty" example:"成人影视学院"` }
ChatMessageBody 消息主体 @Description 消息主体
type CreateGroupRequest ¶
type CreateGroupRequest struct { // MemberIDs 其他成员的用户ID MemberIDs []int64 `json:"member_ids" binding:"required" minLength:"1" maxLength:"50" example:"1,2,3,4"` }
CreateGroupRequest 创建群请求参数 @Description 创建群请求参数
type CreateGroupResponse ¶
type CreateGroupResponse struct { // GroupID 群ID GroupID int64 `json:"group_id" binding:"required" example:"1098"` // GroupName 群名称 GroupName string `json:"group_name" binding:"required" example:"群聊1098"` }
CreateGroupResponse 创建群返回参数 @Description 创建群返回参数
type FindFriendRequest ¶
type FindFriendRequest struct { // UserID 用户ID UserID *int64 `form:"user_id" json:"user_id" example:"1"` // Nickname 昵称 Nickname *string `form:"nickname" json:"nickname" example:"昵称"` // StartID 开始搜索ID,下次搜索用上返回的最大ID StartID *int64 `form:"start_id" json:"start_id" example:"0"` }
FindFriendRequest 查找好友请求参数 @Description 查找好友请求参数
type GetCaptchaRequest ¶ added in v1.0.4
type GetCaptchaRequest struct {
Type string `form:"type" example:"string"`
}
GetCaptchaRequest @Description 获取验证码请求参数
type GetCaptchaResponse ¶ added in v1.0.4
type GetCaptchaResponse struct { // ID 验证码验证ID ID string `json:"id" binding:"required" example:"7uh37xVCN0oGarKZ79nx"` // Type 验证码类型 Type string `json:"type" binding:"required" example:"audio"` // Data 验证码数据;有图片数据,也有音频数据,前端需要根据type生成对应媒体数据 Data string `json:"data" binding:"required"` }
GetCaptchaResponse @Description 获取验证码返回数据
type GetLastChatMessagesRequest ¶ added in v1.0.3
type GetLastChatMessagesRequest struct { // TargetID 目标ID; 朋友ID/群ID/世界频道ID TargetID int64 `form:"target_id" json:"target_id"` // SessionType 会话类型; 1-私人会话;2-群聊会话;99-世界频道会话 SessionType int `form:"session_type" json:"session_type"` }
GetLastChatMessagesRequest @Description 获取最后聊天消息列表请求参数
type JoinGroupRequest ¶
type JoinGroupRequest struct { // GroupID 群ID GroupID int64 `json:"group_id" binding:"required" example:"1098"` }
JoinGroupRequest 入群请求参数 @Description 入群请求参数
type LeaveGroupRequest ¶
type LeaveGroupRequest struct { // GroupID 群ID GroupID int64 `json:"group_id" binding:"required" example:"1098"` }
LeaveGroupRequest 离群请求参数 @Description 离群请求参数
type ProfileInfoResponse ¶
type ProfileInfoResponse struct { Username string `json:"username"` BirthDate string `json:"birth_date" ` Avatar string `json:"avatar"` OnlineStatus int `json:"online_status"` }
ProfileInfoResponse 个人画像的数据结构
type RedisCaptchaStore ¶ added in v1.0.4
type RedisCaptchaStore struct {
// contains filtered or unexported fields
}
RedisCaptchaStore 用于存储验证码的Redis结构
func (*RedisCaptchaStore) Get ¶ added in v1.0.4
func (s *RedisCaptchaStore) Get(id string, clear bool) string
type RemoveGroupMemberRequest ¶
type RemoveGroupMemberRequest struct { // GroupID 群ID GroupID int64 `json:"group_id" binding:"required" min:"1" example:"1"` // UserIDs 当UserIDs为空时,表示主动当前用户退出群组,当不为空是表示将他人提出群组 UserIDs []int64 `json:"user_ids" binding:"required" example:"1,2,3,4"` }
RemoveGroupMemberRequest 移除群成员请求参数 @Description 移除群成员请求参数
type RemoveGroupMemberResponse ¶
type RemoveGroupMemberResponse struct { // Count 成功移除成员数量 Count int64 `json:"count" binding:"required" example:"22"` }
RemoveGroupMemberResponse 移除群成员返回参数 @Description 移除群返回请求参数
type RollbackChatMessageRequest ¶ added in v1.0.9
type RollbackChatMessageRequest struct { // TargetID 目标ID; 朋友ID/群ID/世界频道ID TargetID int64 `form:"target_id" json:"target_id"` // SessionType 会话类型; 1-私人会话;2-群聊会话;99-世界频道会话 SessionType int `form:"session_type" json:"session_type"` // MessageID 消息ID MessageID int64 `form:"message_id" json:"message_id"` }
RollbackChatMessageRequest 回滚聊天消息请求参数
type SendChatMessageRequest ¶
type SendChatMessageRequest struct { // ActionID 行为ID,由前端生成 ActionID string `json:"action_id" example:"8d7a3bcd72"` // SessionType 会话类型; 1:私聊, 2:群聊 SessionType int `json:"session_type" binding:"required" enums:"1,2" example:"1"` // Type 消息类型; 1-纯文本,2-图片,3-语音,4-视频, 5-位置 Type int `json:"type" enums:"1,2,3,4,5" binding:"required" example:"1"` // TargetID 目标ID; 可以是用户ID,也可以是群ID,也可以是世界频道ID TargetID int64 `json:"target_id" binding:"required" example:"1234"` // Body 消息体; Body ChatMessageBody `json:"body" binding:"required"` }
SendChatMessageRequest 聊天发送消息请求参数 @Description 聊天发送消息请求参数
type UpdateFriendInviteRequest ¶
type UpdateFriendInviteRequest struct { // ID 邀请记录ID号 ID int64 `json:"id" binding:"required" min:"1" example:"1"` // Status 设置状态 // 1-确认加为好友关系,2-拒绝加为好友 Status int `json:"status" binding:"required" enums:"1,2" example:"1"` // Reply 回复信息 // status:1 为打招呼 // status:2 为拒绝理由 Reply string `json:"reply" example:"我拒绝"` }
UpdateFriendInviteRequest 更新邀请好友请求 @Description 更新邀请好友请求
type UpdateFriendRequest ¶
type UpdateFriendRequest struct { // UserID 对方的用户ID UserID int64 `json:"user_id" binding:"required" min:"1" example:"1"` // Status 好友状态, 0-删除对方 Status *int `json:"status" enums:"0" example:"0"` // BlockStatus 黑名单状态, 0-把对方加入黑名单, 1-将对方从黑名单中移除 BlockStatus *int `json:"block_status" enums:"0" example:"1"` // Remark 备注 Remark *string `json:"remark" example:"这个是我基友"` }
UpdateFriendRequest 更新朋友信息请求参数 @Description 更新朋友信息请求参数
type UpdateGroupMemberRequest ¶
type UpdateGroupMemberRequest struct { // GroupID 群ID GroupID int64 `json:"group_id" binding:"required" example:"1098"` // UserID 成员用户ID UserID int64 `json:"user_id" binding:"required" example:"45"` // Role 角色, 只能群主才可操作 Role *int `json:"role,omitempty" enums:"0,2" example:"0"` // SpeakStatus 发言权限, 管理者以上都可以操作, 管理员不能禁言管理员及以上权限的成员 SpeakStatus *int `json:"speak_status" enums:"0,1" example:"1"` }
UpdateGroupMemberRequest @Description 更新群成员信息请求参数
type UpdateGroupRequest ¶
type UpdateGroupRequest struct { // GroupID 群组ID GroupID int64 `json:"group_id" binding:"required" example:"1098"` // Name 群名称 Name *string `json:"name,omitempty" minLength:"1" maxLength:"50" example:"昵称"` // SpeakStatus 发言状态, 必须为管理员以上级别 SpeakStatus *int `json:"speak_status,omitempty" enums:"0,1" example:"1"` // OwnerID 新群主 OwnerID *int64 `json:"owner_id,omitempty" example:"1"` }
UpdateGroupRequest 更新群组信息请求 @Description 更新群组信息请求参数
type User ¶
type User struct { // ID 用户ID ID int64 `json:"id" example:"10096"` // Username 用户名 Username string `json:"username,omitempty" example:"admin"` // Nickname 用户昵称 Nickname string `json:"nickname" example:"昵称"` // BirthDate 出生日期 BirthDate *time.Time `json:"birth_date,omitempty" example:"2018-01-02"` // Avatar 头像地址 Avatar string `json:"avatar,omitempty" format:"url" example:"https://www.baidu.com/logo.png"` // OnlineStatus 在线状态 OnlineStatus int `json:"online_status,omitempty" enums:"0,1" example:"1"` }
User @Description 用户信息结构
type UserClaims ¶
type UserClaims struct { UserID int64 `json:"user_id"` jwt.RegisteredClaims }
UserClaims 用户认证使用的一些解码资料
type WebsocketMessageRequest ¶
type WebsocketMessageRequest struct { Action string `json:"action"` ActionID string `json:"action_id"` Data any `json:"data"` }
WebsocketMessageRequest websocket请求参数
type WebsocketMessageResponse ¶
type WebsocketMessageResponse struct { Action string `json:"action"` ActionID string `json:"action_id"` Data any `json:"data"` }
WebsocketMessageResponse websocket返回数据