- Updated PostHandler to include channel information in post responses. - Introduced PostChannelBrief DTO to represent channel details associated with posts. - Modified post conversion functions to support channel data, ensuring proper mapping of channel IDs to channel names. - Enhanced ChannelRepository and ChannelService to facilitate batch retrieval of channels by IDs. - Updated wire generation to inject channel service into post handler for improved functionality.
1292 lines
48 KiB
Go
1292 lines
48 KiB
Go
package dto
|
||
|
||
import (
|
||
"carrot_bbs/internal/model"
|
||
"time"
|
||
)
|
||
|
||
// ==================== User DTOs ====================
|
||
|
||
// UserResponse 用户公开信息响应(不包含敏感信息)
|
||
type UserResponse struct {
|
||
ID string `json:"id"`
|
||
Username string `json:"username"`
|
||
Nickname string `json:"nickname"`
|
||
EmailVerified bool `json:"email_verified"`
|
||
Avatar string `json:"avatar"`
|
||
CoverURL string `json:"cover_url"`
|
||
Bio string `json:"bio"`
|
||
Website string `json:"website"`
|
||
Location string `json:"location"`
|
||
PostsCount int `json:"posts_count"`
|
||
FollowersCount int `json:"followers_count"`
|
||
FollowingCount int `json:"following_count"`
|
||
IsFollowing bool `json:"is_following"`
|
||
IsFollowingMe bool `json:"is_following_me"`
|
||
CreatedAt string `json:"created_at"`
|
||
}
|
||
|
||
// UserSelfResponse 用户自身信息响应(包含敏感信息,仅本人可见)
|
||
type UserSelfResponse struct {
|
||
ID string `json:"id"`
|
||
Username string `json:"username"`
|
||
Nickname string `json:"nickname"`
|
||
Email *string `json:"email,omitempty"`
|
||
Phone *string `json:"phone,omitempty"`
|
||
EmailVerified bool `json:"email_verified"`
|
||
Avatar string `json:"avatar"`
|
||
CoverURL string `json:"cover_url"`
|
||
Bio string `json:"bio"`
|
||
Website string `json:"website"`
|
||
Location string `json:"location"`
|
||
PostsCount int `json:"posts_count"`
|
||
FollowersCount int `json:"followers_count"`
|
||
FollowingCount int `json:"following_count"`
|
||
IsVerified bool `json:"is_verified"`
|
||
CreatedAt string `json:"created_at"`
|
||
}
|
||
|
||
// UserDetailResponse 用户详情响应(仅本人可见,包含敏感信息)
|
||
type UserDetailResponse struct {
|
||
ID string `json:"id"`
|
||
Username string `json:"username"`
|
||
Nickname string `json:"nickname"`
|
||
Email *string `json:"email,omitempty"`
|
||
EmailVerified bool `json:"email_verified"`
|
||
Phone *string `json:"phone,omitempty"`
|
||
Avatar string `json:"avatar"`
|
||
CoverURL string `json:"cover_url"`
|
||
Bio string `json:"bio"`
|
||
Website string `json:"website"`
|
||
Location string `json:"location"`
|
||
PostsCount int `json:"posts_count"`
|
||
FollowersCount int `json:"followers_count"`
|
||
FollowingCount int `json:"following_count"`
|
||
IsVerified bool `json:"is_verified"`
|
||
IsFollowing bool `json:"is_following"`
|
||
IsFollowingMe bool `json:"is_following_me"`
|
||
CreatedAt string `json:"created_at"`
|
||
}
|
||
|
||
// ==================== Admin User DTOs ====================
|
||
|
||
// AdminUserListResponse 管理端用户列表响应
|
||
type AdminUserListResponse struct {
|
||
ID string `json:"id"`
|
||
Username string `json:"username"`
|
||
Nickname string `json:"nickname"`
|
||
Email *string `json:"email,omitempty"`
|
||
Phone *string `json:"phone,omitempty"`
|
||
EmailVerified bool `json:"email_verified"`
|
||
Avatar string `json:"avatar"`
|
||
Status string `json:"status"`
|
||
PostsCount int `json:"posts_count"`
|
||
FollowersCount int `json:"followers_count"`
|
||
FollowingCount int `json:"following_count"`
|
||
LastLoginAt string `json:"last_login_at,omitempty"`
|
||
LastLoginIP string `json:"last_login_ip,omitempty"`
|
||
CreatedAt string `json:"created_at"`
|
||
}
|
||
|
||
// AdminUserDetailResponse 管理端用户详情响应
|
||
type AdminUserDetailResponse struct {
|
||
ID string `json:"id"`
|
||
Username string `json:"username"`
|
||
Nickname string `json:"nickname"`
|
||
Email *string `json:"email"`
|
||
Phone *string `json:"phone"`
|
||
EmailVerified bool `json:"email_verified"`
|
||
Avatar string `json:"avatar"`
|
||
CoverURL string `json:"cover_url"`
|
||
Bio string `json:"bio"`
|
||
Website string `json:"website"`
|
||
Location string `json:"location"`
|
||
IsVerified bool `json:"is_verified"`
|
||
Status string `json:"status"`
|
||
PostsCount int `json:"posts_count"`
|
||
CommentsCount int64 `json:"comments_count"`
|
||
FollowersCount int `json:"followers_count"`
|
||
FollowingCount int `json:"following_count"`
|
||
LastLoginAt string `json:"last_login_at,omitempty"`
|
||
LastLoginIP string `json:"last_login_ip,omitempty"`
|
||
CreatedAt string `json:"created_at"`
|
||
UpdatedAt string `json:"updated_at"`
|
||
}
|
||
|
||
// AdminUpdateUserStatusRequest 更新用户状态请求
|
||
type AdminUpdateUserStatusRequest struct {
|
||
Status string `json:"status" binding:"required,oneof=active banned"`
|
||
}
|
||
|
||
// ==================== Post DTOs ====================
|
||
|
||
// PostChannelBrief 帖子所属频道(列表/详情卡片展示)
|
||
type PostChannelBrief struct {
|
||
ID string `json:"id"`
|
||
Name string `json:"name"`
|
||
}
|
||
|
||
// PostImageResponse 帖子图片响应
|
||
type PostImageResponse struct {
|
||
ID string `json:"id"`
|
||
URL string `json:"url"`
|
||
ThumbnailURL string `json:"thumbnail_url"`
|
||
PreviewURL string `json:"preview_url"` // 列表/网格预览图
|
||
PreviewURLLarge string `json:"preview_url_large"` // 详情页预览图
|
||
Width int `json:"width"`
|
||
Height int `json:"height"`
|
||
}
|
||
|
||
// PostResponse 帖子响应(列表用)
|
||
type PostResponse struct {
|
||
ID string `json:"id"`
|
||
UserID string `json:"user_id"`
|
||
ChannelID *string `json:"channel_id,omitempty"`
|
||
Title string `json:"title"`
|
||
Content string `json:"content"`
|
||
Images []PostImageResponse `json:"images"`
|
||
Status string `json:"status,omitempty"`
|
||
LikesCount int `json:"likes_count"`
|
||
CommentsCount int `json:"comments_count"`
|
||
FavoritesCount int `json:"favorites_count"`
|
||
SharesCount int `json:"shares_count"`
|
||
ViewsCount int `json:"views_count"`
|
||
IsPinned bool `json:"is_pinned"`
|
||
IsLocked bool `json:"is_locked"`
|
||
IsVote bool `json:"is_vote"`
|
||
CreatedAt string `json:"created_at"`
|
||
UpdatedAt string `json:"updated_at"`
|
||
ContentEditedAt string `json:"content_edited_at,omitempty"`
|
||
Author *UserResponse `json:"author"`
|
||
IsLiked bool `json:"is_liked"`
|
||
IsFavorited bool `json:"is_favorited"`
|
||
Channel *PostChannelBrief `json:"channel,omitempty"`
|
||
}
|
||
|
||
// PostDetailResponse 帖子详情响应
|
||
type PostDetailResponse struct {
|
||
ID string `json:"id"`
|
||
UserID string `json:"user_id"`
|
||
ChannelID *string `json:"channel_id,omitempty"`
|
||
Title string `json:"title"`
|
||
Content string `json:"content"`
|
||
Images []PostImageResponse `json:"images"`
|
||
Status string `json:"status"`
|
||
LikesCount int `json:"likes_count"`
|
||
CommentsCount int `json:"comments_count"`
|
||
FavoritesCount int `json:"favorites_count"`
|
||
SharesCount int `json:"shares_count"`
|
||
ViewsCount int `json:"views_count"`
|
||
IsPinned bool `json:"is_pinned"`
|
||
IsLocked bool `json:"is_locked"`
|
||
IsVote bool `json:"is_vote"`
|
||
CreatedAt string `json:"created_at"`
|
||
UpdatedAt string `json:"updated_at"`
|
||
ContentEditedAt string `json:"content_edited_at,omitempty"`
|
||
Author *UserResponse `json:"author"`
|
||
IsLiked bool `json:"is_liked"`
|
||
IsFavorited bool `json:"is_favorited"`
|
||
Channel *PostChannelBrief `json:"channel,omitempty"`
|
||
}
|
||
|
||
// ==================== Comment DTOs ====================
|
||
|
||
// CommentImageResponse 评论图片响应
|
||
type CommentImageResponse struct {
|
||
URL string `json:"url"`
|
||
}
|
||
|
||
// CommentResponse 评论响应(扁平化结构,类似B站/抖音)
|
||
// 第一层级正常展示,第二三四五层级在第一层级的评论区扁平展示
|
||
type CommentResponse struct {
|
||
ID string `json:"id"`
|
||
PostID string `json:"post_id"`
|
||
UserID string `json:"user_id"`
|
||
ParentID *string `json:"parent_id"`
|
||
RootID *string `json:"root_id"`
|
||
Content string `json:"content"`
|
||
Images []CommentImageResponse `json:"images"`
|
||
LikesCount int `json:"likes_count"`
|
||
RepliesCount int `json:"replies_count"`
|
||
CreatedAt string `json:"created_at"`
|
||
Author *UserResponse `json:"author"`
|
||
IsLiked bool `json:"is_liked"`
|
||
TargetID *string `json:"target_id,omitempty"` // 被回复的评论ID,前端根据此ID找到被回复用户的昵称
|
||
Replies []*CommentResponse `json:"replies,omitempty"` // 子回复列表(扁平化,所有层级都在这里)
|
||
}
|
||
|
||
// ==================== Notification DTOs ====================
|
||
|
||
// NotificationResponse 通知响应
|
||
type NotificationResponse struct {
|
||
ID string `json:"id"`
|
||
UserID string `json:"user_id"`
|
||
Type string `json:"type"`
|
||
Title string `json:"title"`
|
||
Content string `json:"content"`
|
||
Data string `json:"data"`
|
||
IsRead bool `json:"is_read"`
|
||
CreatedAt string `json:"created_at"`
|
||
}
|
||
|
||
// ==================== Message Segment DTOs ====================
|
||
|
||
// SegmentType Segment类型
|
||
type SegmentType string
|
||
|
||
const (
|
||
SegmentTypeText SegmentType = "text"
|
||
SegmentTypeImage SegmentType = "image"
|
||
SegmentTypeVoice SegmentType = "voice"
|
||
SegmentTypeVideo SegmentType = "video"
|
||
SegmentTypeFile SegmentType = "file"
|
||
SegmentTypeAt SegmentType = "at"
|
||
SegmentTypeReply SegmentType = "reply"
|
||
SegmentTypeFace SegmentType = "face"
|
||
SegmentTypeLink SegmentType = "link"
|
||
)
|
||
|
||
// TextSegmentData 文本数据
|
||
type TextSegmentData struct {
|
||
Text string `json:"text"`
|
||
}
|
||
|
||
// ImageSegmentData 图片数据
|
||
type ImageSegmentData struct {
|
||
URL string `json:"url"`
|
||
Width int `json:"width,omitzero"`
|
||
Height int `json:"height,omitzero"`
|
||
ThumbnailURL string `json:"thumbnail_url,omitempty"`
|
||
FileSize int64 `json:"file_size,omitzero"`
|
||
}
|
||
|
||
// VoiceSegmentData 语音数据
|
||
type VoiceSegmentData struct {
|
||
URL string `json:"url"`
|
||
Duration int `json:"duration,omitzero"` // 秒
|
||
FileSize int64 `json:"file_size,omitzero"`
|
||
}
|
||
|
||
// VideoSegmentData 视频数据
|
||
type VideoSegmentData struct {
|
||
URL string `json:"url"`
|
||
Width int `json:"width,omitzero"`
|
||
Height int `json:"height,omitzero"`
|
||
Duration int `json:"duration,omitzero"` // 秒
|
||
ThumbnailURL string `json:"thumbnail_url,omitempty"`
|
||
FileSize int64 `json:"file_size,omitzero"`
|
||
}
|
||
|
||
// FileSegmentData 文件数据
|
||
type FileSegmentData struct {
|
||
URL string `json:"url"`
|
||
Name string `json:"name"`
|
||
Size int64 `json:"size,omitzero"`
|
||
MimeType string `json:"mime_type,omitempty"`
|
||
}
|
||
|
||
// AtSegmentData @数据
|
||
type AtSegmentData struct {
|
||
UserID string `json:"user_id"` // "all" 表示@所有人
|
||
Nickname string `json:"nickname,omitempty"`
|
||
}
|
||
|
||
// ReplySegmentData 回复数据
|
||
type ReplySegmentData struct {
|
||
ID string `json:"id"` // 被回复消息的ID
|
||
}
|
||
|
||
// FaceSegmentData 表情数据
|
||
type FaceSegmentData struct {
|
||
ID int `json:"id,omitzero"`
|
||
Name string `json:"name,omitempty"`
|
||
URL string `json:"url,omitempty"`
|
||
}
|
||
|
||
// LinkSegmentData 链接数据
|
||
type LinkSegmentData struct {
|
||
URL string `json:"url"`
|
||
Title string `json:"title,omitempty"`
|
||
Description string `json:"description,omitempty"`
|
||
Image string `json:"image,omitempty"`
|
||
}
|
||
|
||
// ==================== Message DTOs ====================
|
||
|
||
// MessageResponse 消息响应
|
||
type MessageResponse struct {
|
||
ID string `json:"id"`
|
||
ConversationID string `json:"conversation_id"`
|
||
SenderID string `json:"sender_id"`
|
||
Seq int64 `json:"seq"`
|
||
Segments model.MessageSegments `json:"segments"` // 消息链(必须)
|
||
ReplyToID *string `json:"reply_to_id,omitempty"` // 被回复消息的ID(用于关联查找)
|
||
Status string `json:"status"`
|
||
Category string `json:"category,omitempty"` // 消息类别:chat, notification, announcement
|
||
CreatedAt string `json:"created_at"`
|
||
Sender *UserResponse `json:"sender"`
|
||
}
|
||
|
||
// ConversationResponse 会话响应
|
||
type ConversationResponse struct {
|
||
ID string `json:"id"`
|
||
Type string `json:"type"`
|
||
IsPinned bool `json:"is_pinned"`
|
||
Group *GroupResponse `json:"group,omitempty"`
|
||
LastSeq int64 `json:"last_seq"`
|
||
LastMessage *MessageResponse `json:"last_message"`
|
||
LastMessageAt string `json:"last_message_at"`
|
||
UnreadCount int `json:"unread_count"`
|
||
Participants []*UserResponse `json:"participants,omitempty"` // 私聊时使用
|
||
MemberCount int `json:"member_count,omitempty"` // 群聊时使用
|
||
CreatedAt string `json:"created_at"`
|
||
UpdatedAt string `json:"updated_at"`
|
||
}
|
||
|
||
// ConversationParticipantResponse 会话参与者响应
|
||
type ConversationParticipantResponse struct {
|
||
UserID string `json:"user_id"`
|
||
LastReadSeq int64 `json:"last_read_seq"`
|
||
Muted bool `json:"muted"`
|
||
IsPinned bool `json:"is_pinned"`
|
||
}
|
||
|
||
// ==================== Auth DTOs ====================
|
||
|
||
// LoginResponse 登录响应
|
||
type LoginResponse struct {
|
||
User *UserResponse `json:"user"`
|
||
AccessToken string `json:"access_token"`
|
||
RefreshToken string `json:"refresh_token"`
|
||
}
|
||
|
||
// RegisterResponse 注册响应
|
||
type RegisterResponse struct {
|
||
User *UserResponse `json:"user"`
|
||
AccessToken string `json:"access_token"`
|
||
RefreshToken string `json:"refresh_token"`
|
||
}
|
||
|
||
// RefreshTokenResponse 刷新Token响应
|
||
type RefreshTokenResponse struct {
|
||
AccessToken string `json:"access_token"`
|
||
RefreshToken string `json:"refresh_token"`
|
||
}
|
||
|
||
// ==================== Common DTOs ====================
|
||
|
||
// SuccessResponse 通用成功响应
|
||
type SuccessResponse struct {
|
||
Success bool `json:"success"`
|
||
Message string `json:"message"`
|
||
}
|
||
|
||
// AvailableResponse 可用性检查响应
|
||
type AvailableResponse struct {
|
||
Available bool `json:"available"`
|
||
}
|
||
|
||
// CountResponse 数量响应
|
||
type CountResponse struct {
|
||
Count int `json:"count"`
|
||
}
|
||
|
||
// URLResponse URL响应
|
||
type URLResponse struct {
|
||
URL string `json:"url"`
|
||
}
|
||
|
||
// ==================== Chat Request DTOs ====================
|
||
|
||
// CreateConversationRequest 创建会话请求
|
||
type CreateConversationRequest struct {
|
||
UserID string `json:"user_id" binding:"required"` // 目标用户ID (UUID格式)
|
||
}
|
||
|
||
// SendMessageRequest 发送消息请求
|
||
type SendMessageRequest struct {
|
||
Segments model.MessageSegments `json:"segments" binding:"required"` // 消息链(必须)
|
||
ReplyToID *string `json:"reply_to_id,omitempty"` // 回复的消息ID (string类型)
|
||
}
|
||
|
||
// MarkReadRequest 标记已读请求
|
||
type MarkReadRequest struct {
|
||
LastReadSeq int64 `json:"last_read_seq" binding:"required"` // 已读到的seq位置
|
||
}
|
||
|
||
// SetConversationPinnedRequest 设置会话置顶请求
|
||
type SetConversationPinnedRequest struct {
|
||
ConversationID string `json:"conversation_id" binding:"required"`
|
||
IsPinned bool `json:"is_pinned"`
|
||
}
|
||
|
||
// ==================== Chat Response DTOs ====================
|
||
|
||
// ConversationListResponse 会话列表响应
|
||
type ConversationListResponse struct {
|
||
Conversations []*ConversationResponse `json:"list"`
|
||
Total int64 `json:"total"`
|
||
Page int `json:"page"`
|
||
PageSize int `json:"page_size"`
|
||
}
|
||
|
||
// ConversationDetailResponse 会话详情响应
|
||
type ConversationDetailResponse struct {
|
||
ID string `json:"id"`
|
||
Type string `json:"type"`
|
||
IsPinned bool `json:"is_pinned"`
|
||
LastSeq int64 `json:"last_seq"`
|
||
LastMessage *MessageResponse `json:"last_message"`
|
||
LastMessageAt string `json:"last_message_at"`
|
||
UnreadCount int64 `json:"unread_count"`
|
||
Participants []*UserResponse `json:"participants"`
|
||
MyLastReadSeq int64 `json:"my_last_read_seq"` // 当前用户的已读位置
|
||
OtherLastReadSeq int64 `json:"other_last_read_seq"` // 对方用户的已读位置
|
||
CreatedAt string `json:"created_at"`
|
||
UpdatedAt string `json:"updated_at"`
|
||
}
|
||
|
||
// UnreadCountResponse 未读数响应
|
||
type UnreadCountResponse struct {
|
||
TotalUnreadCount int64 `json:"total_unread_count"` // 所有会话的未读总数
|
||
}
|
||
|
||
// ConversationUnreadCountResponse 单个会话未读数响应
|
||
type ConversationUnreadCountResponse struct {
|
||
ConversationID string `json:"conversation_id"`
|
||
UnreadCount int64 `json:"unread_count"`
|
||
}
|
||
|
||
// MessageListResponse 消息列表响应
|
||
type MessageListResponse struct {
|
||
Messages []*MessageResponse `json:"messages"`
|
||
Total int64 `json:"total"`
|
||
Page int `json:"page"`
|
||
PageSize int `json:"page_size"`
|
||
}
|
||
|
||
// MessageSyncResponse 消息同步响应(增量同步)
|
||
type MessageSyncResponse struct {
|
||
Messages []*MessageResponse `json:"messages"`
|
||
HasMore bool `json:"has_more"`
|
||
}
|
||
|
||
// ==================== 设备Token DTOs ====================
|
||
|
||
// RegisterDeviceRequest 注册设备请求
|
||
type RegisterDeviceRequest struct {
|
||
DeviceID string `json:"device_id" binding:"required"`
|
||
DeviceType string `json:"device_type" binding:"required,oneof=ios android web"`
|
||
PushToken string `json:"push_token"`
|
||
DeviceName string `json:"device_name"`
|
||
}
|
||
|
||
// DeviceTokenResponse 设备Token响应
|
||
type DeviceTokenResponse struct {
|
||
ID int64 `json:"id"`
|
||
DeviceID string `json:"device_id"`
|
||
DeviceType string `json:"device_type"`
|
||
IsActive bool `json:"is_active"`
|
||
DeviceName string `json:"device_name"`
|
||
LastUsedAt time.Time `json:"last_used_at,omitzero"`
|
||
CreatedAt time.Time `json:"created_at"`
|
||
}
|
||
|
||
// ==================== 推送记录 DTOs ====================
|
||
|
||
// PushRecordResponse 推送记录响应
|
||
type PushRecordResponse struct {
|
||
ID int64 `json:"id"`
|
||
MessageID string `json:"message_id"`
|
||
PushChannel string `json:"push_channel"`
|
||
PushStatus string `json:"push_status"`
|
||
RetryCount int `json:"retry_count,omitzero"`
|
||
PushedAt time.Time `json:"pushed_at,omitzero"`
|
||
DeliveredAt time.Time `json:"delivered_at,omitzero"`
|
||
CreatedAt time.Time `json:"created_at"`
|
||
}
|
||
|
||
// PushRecordListResponse 推送记录列表响应
|
||
type PushRecordListResponse struct {
|
||
Records []*PushRecordResponse `json:"records"`
|
||
Total int64 `json:"total"`
|
||
}
|
||
|
||
// ==================== 系统消息 DTOs ====================
|
||
|
||
// SystemMessageResponse 系统消息响应
|
||
type SystemMessageResponse struct {
|
||
ID string `json:"id"`
|
||
SenderID string `json:"sender_id"`
|
||
ReceiverID string `json:"receiver_id"`
|
||
Content string `json:"content"`
|
||
Category string `json:"category"`
|
||
SystemType string `json:"system_type"`
|
||
ExtraData map[string]interface{} `json:"extra_data,omitempty"`
|
||
IsRead bool `json:"is_read"`
|
||
CreatedAt time.Time `json:"created_at"`
|
||
}
|
||
|
||
// SystemMessageListResponse 系统消息列表响应
|
||
type SystemMessageListResponse struct {
|
||
Messages []*SystemMessageResponse `json:"messages"`
|
||
Total int64 `json:"total"`
|
||
Page int `json:"page"`
|
||
PageSize int `json:"page_size"`
|
||
}
|
||
|
||
// SystemUnreadCountResponse 系统消息未读数响应
|
||
type SystemUnreadCountResponse struct {
|
||
UnreadCount int64 `json:"unread_count"`
|
||
}
|
||
|
||
// SystemMessageCursorPageResponse 系统消息游标分页响应
|
||
type SystemMessageCursorPageResponse struct {
|
||
Items []*SystemMessageResponse `json:"list"`
|
||
NextCursor string `json:"next_cursor"`
|
||
PrevCursor string `json:"prev_cursor"`
|
||
HasMore bool `json:"has_more"`
|
||
}
|
||
|
||
// ==================== 时间格式化 ====================
|
||
|
||
// FormatTime 格式化时间
|
||
func FormatTime(t time.Time) string {
|
||
if t.IsZero() {
|
||
return ""
|
||
}
|
||
return t.Format("2006-01-02T15:04:05Z07:00")
|
||
}
|
||
|
||
// FormatTimePointer 格式化时间指针
|
||
func FormatTimePointer(t *time.Time) string {
|
||
if t == nil {
|
||
return ""
|
||
}
|
||
return FormatTime(*t)
|
||
}
|
||
|
||
// ==================== Group DTOs ====================
|
||
|
||
// CreateGroupRequest 创建群组请求
|
||
type CreateGroupRequest struct {
|
||
Name string `json:"name" binding:"required,max=50"`
|
||
Description string `json:"description" binding:"max=500"`
|
||
MemberIDs []string `json:"member_ids"`
|
||
}
|
||
|
||
// UpdateGroupRequest 更新群组请求
|
||
type UpdateGroupRequest struct {
|
||
Name string `json:"name" binding:"omitempty,max=50"`
|
||
Description string `json:"description" binding:"omitempty,max=500"`
|
||
Avatar string `json:"avatar" binding:"omitempty,url"`
|
||
}
|
||
|
||
// InviteMembersRequest 邀请成员请求
|
||
type InviteMembersRequest struct {
|
||
MemberIDs []string `json:"member_ids" binding:"required,min=1"`
|
||
}
|
||
|
||
// TransferOwnerRequest 转让群主请求
|
||
type TransferOwnerRequest struct {
|
||
NewOwnerID string `json:"new_owner_id" binding:"required"`
|
||
}
|
||
|
||
// SetRoleRequest 设置角色请求
|
||
type SetRoleRequest struct {
|
||
Role string `json:"role" binding:"required,oneof=admin member"`
|
||
}
|
||
|
||
// SetNicknameRequest 设置昵称请求
|
||
type SetNicknameRequest struct {
|
||
Nickname string `json:"nickname" binding:"max=50"`
|
||
}
|
||
|
||
// MuteMemberRequest 禁言成员请求
|
||
type MuteMemberRequest struct {
|
||
Muted bool `json:"muted"`
|
||
}
|
||
|
||
// SetMuteAllRequest 设置全员禁言请求
|
||
type SetMuteAllRequest struct {
|
||
MuteAll bool `json:"mute_all"`
|
||
}
|
||
|
||
// SetJoinTypeRequest 设置加群方式请求
|
||
type SetJoinTypeRequest struct {
|
||
JoinType int `json:"join_type" binding:"min=0,max=2"`
|
||
}
|
||
|
||
// CreateAnnouncementRequest 创建群公告请求
|
||
type CreateAnnouncementRequest struct {
|
||
Content string `json:"content" binding:"required,max=2000"`
|
||
}
|
||
|
||
// GroupResponse 群组响应
|
||
type GroupResponse struct {
|
||
ID string `json:"id"`
|
||
Name string `json:"name"`
|
||
Avatar string `json:"avatar"`
|
||
Description string `json:"description"`
|
||
OwnerID string `json:"owner_id"`
|
||
MemberCount int `json:"member_count"`
|
||
MaxMembers int `json:"max_members"`
|
||
JoinType int `json:"join_type"`
|
||
MuteAll bool `json:"mute_all"`
|
||
CreatedAt string `json:"created_at"`
|
||
}
|
||
|
||
// GroupMemberResponse 群成员响应
|
||
type GroupMemberResponse struct {
|
||
ID string `json:"id"`
|
||
GroupID string `json:"group_id"`
|
||
UserID string `json:"user_id"`
|
||
Role string `json:"role"`
|
||
Nickname string `json:"nickname"`
|
||
Muted bool `json:"muted"`
|
||
JoinTime string `json:"join_time"`
|
||
User *UserResponse `json:"user,omitempty"`
|
||
}
|
||
|
||
// GroupAnnouncementResponse 群公告响应
|
||
type GroupAnnouncementResponse struct {
|
||
ID string `json:"id"`
|
||
GroupID string `json:"group_id"`
|
||
Content string `json:"content"`
|
||
AuthorID string `json:"author_id"`
|
||
IsPinned bool `json:"is_pinned"`
|
||
CreatedAt string `json:"created_at"`
|
||
}
|
||
|
||
// GroupListResponse 群组列表响应
|
||
type GroupListResponse struct {
|
||
List []*GroupResponse `json:"list"`
|
||
Total int64 `json:"total"`
|
||
Page int `json:"page"`
|
||
PageSize int `json:"page_size"`
|
||
}
|
||
|
||
// GroupMemberListResponse 群成员列表响应
|
||
type GroupMemberListResponse struct {
|
||
List []*GroupMemberResponse `json:"list"`
|
||
Total int64 `json:"total"`
|
||
Page int `json:"page"`
|
||
PageSize int `json:"page_size"`
|
||
}
|
||
|
||
// GroupAnnouncementListResponse 群公告列表响应
|
||
type GroupAnnouncementListResponse struct {
|
||
List []*GroupAnnouncementResponse `json:"list"`
|
||
Total int64 `json:"total"`
|
||
Page int `json:"page"`
|
||
PageSize int `json:"page_size"`
|
||
}
|
||
|
||
// ==================== WebSocket Event DTOs ====================
|
||
|
||
// WSEventResponse WebSocket事件响应结构体
|
||
// 用于后端推送消息给前端的标准格式
|
||
type WSEventResponse struct {
|
||
ID string `json:"id"` // 事件唯一ID (UUID)
|
||
Time int64 `json:"time"` // 时间戳 (毫秒)
|
||
Type string `json:"type"` // 事件类型 (message, notification, system等)
|
||
DetailType string `json:"detail_type"` // 详细类型 (private, group, like, comment等)
|
||
Seq string `json:"seq"` // 消息序列号
|
||
Segments model.MessageSegments `json:"segments"` // 消息段数组
|
||
SenderID string `json:"sender_id"` // 发送者用户ID
|
||
}
|
||
|
||
// ==================== WebSocket Request DTOs ====================
|
||
|
||
// SendMessageParams 发送消息参数(用于 REST API)
|
||
type SendMessageParams struct {
|
||
DetailType string `json:"detail_type"` // 消息类型: private, group
|
||
ConversationID string `json:"conversation_id"` // 会话ID
|
||
Segments model.MessageSegments `json:"segments"` // 消息内容(消息段数组)
|
||
ReplyToID *string `json:"reply_to_id,omitempty"` // 回复的消息ID
|
||
}
|
||
|
||
// DeleteMsgParams 撤回消息参数
|
||
type DeleteMsgParams struct {
|
||
MessageID string `json:"message_id"` // 消息ID
|
||
}
|
||
|
||
// ==================== Group Action Params ====================
|
||
|
||
// SetGroupKickParams 群组踢人参数
|
||
type SetGroupKickParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
UserID string `json:"user_id"` // 被踢用户ID
|
||
RejectAddRequest bool `json:"reject_add_request"` // 是否拒绝再次加群
|
||
}
|
||
|
||
// SetGroupBanParams 群组单人禁言参数
|
||
type SetGroupBanParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
UserID string `json:"user_id"` // 被禁言用户ID
|
||
Duration int64 `json:"duration"` // 禁言时长(秒),0表示解除禁言
|
||
}
|
||
|
||
// SetGroupWholeBanParams 群组全员禁言参数
|
||
type SetGroupWholeBanParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
Enable bool `json:"enable"` // 是否开启全员禁言
|
||
}
|
||
|
||
// SetGroupAdminParams 群组设置管理员参数
|
||
type SetGroupAdminParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
UserID string `json:"user_id"` // 被设置的用户ID
|
||
Enable bool `json:"enable"` // 是否设置为管理员
|
||
}
|
||
|
||
// SetGroupNameParams 设置群名参数
|
||
type SetGroupNameParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
GroupName string `json:"group_name"` // 新群名
|
||
}
|
||
|
||
// SetGroupAvatarParams 设置群头像参数
|
||
type SetGroupAvatarParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
Avatar string `json:"avatar"` // 头像URL
|
||
}
|
||
|
||
// SetGroupLeaveParams 退出群组参数
|
||
type SetGroupLeaveParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
}
|
||
|
||
// SetGroupAddRequestParams 处理加群请求参数
|
||
type SetGroupAddRequestParams struct {
|
||
Flag string `json:"flag"` // 加群请求的flag标识
|
||
Approve bool `json:"approve"` // 是否同意
|
||
Reason string `json:"reason"` // 拒绝理由(当approve为false时)
|
||
}
|
||
|
||
// GetConversationListParams 获取会话列表参数
|
||
type GetConversationListParams struct {
|
||
Page int `json:"page"` // 页码
|
||
PageSize int `json:"page_size"` // 每页数量
|
||
}
|
||
|
||
// GetGroupInfoParams 获取群信息参数
|
||
type GetGroupInfoParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
}
|
||
|
||
// GetGroupMemberListParams 获取群成员列表参数
|
||
type GetGroupMemberListParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
Page int `json:"page"` // 页码
|
||
PageSize int `json:"page_size"` // 每页数量
|
||
}
|
||
|
||
// ==================== Conversation Action Params ====================
|
||
|
||
// CreateConversationParams 创建会话参数
|
||
type CreateConversationParams struct {
|
||
UserID string `json:"user_id"` // 目标用户ID(私聊)
|
||
}
|
||
|
||
// MarkReadParams 标记已读参数
|
||
type MarkReadParams struct {
|
||
ConversationID string `json:"conversation_id"` // 会话ID
|
||
LastReadSeq int64 `json:"last_read_seq"` // 最后已读消息序号
|
||
}
|
||
|
||
// SetConversationPinnedParams 设置会话置顶参数
|
||
type SetConversationPinnedParams struct {
|
||
ConversationID string `json:"conversation_id"` // 会话ID
|
||
IsPinned bool `json:"is_pinned"` // 是否置顶
|
||
}
|
||
|
||
// ==================== Group Action Params (Additional) ====================
|
||
|
||
// CreateGroupParams 创建群组参数
|
||
type CreateGroupParams struct {
|
||
Name string `json:"name"` // 群名
|
||
Description string `json:"description,omitempty"` // 群描述
|
||
MemberIDs []string `json:"member_ids,omitempty"` // 初始成员ID列表
|
||
}
|
||
|
||
// GetUserGroupsParams 获取用户群组列表参数
|
||
type GetUserGroupsParams struct {
|
||
Page int `json:"page"` // 页码
|
||
PageSize int `json:"page_size"` // 每页数量
|
||
}
|
||
|
||
// TransferOwnerParams 转让群主参数
|
||
type TransferOwnerParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
NewOwnerID string `json:"new_owner_id"` // 新群主ID
|
||
}
|
||
|
||
// InviteMembersParams 邀请成员参数
|
||
type InviteMembersParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
MemberIDs []string `json:"member_ids"` // 被邀请的用户ID列表
|
||
}
|
||
|
||
// JoinGroupParams 加入群组参数
|
||
type JoinGroupParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
}
|
||
|
||
// SetNicknameParams 设置群内昵称参数
|
||
type SetNicknameParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
Nickname string `json:"nickname"` // 群内昵称
|
||
}
|
||
|
||
// SetJoinTypeParams 设置加群方式参数
|
||
type SetJoinTypeParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
JoinType int `json:"join_type"` // 加群方式:0-允许任何人加入,1-需要审批,2-不允许加入
|
||
}
|
||
|
||
// CreateAnnouncementParams 创建群公告参数
|
||
type CreateAnnouncementParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
Content string `json:"content"` // 公告内容
|
||
}
|
||
|
||
// GetAnnouncementsParams 获取群公告列表参数
|
||
type GetAnnouncementsParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
Page int `json:"page"` // 页码
|
||
PageSize int `json:"page_size"` // 每页数量
|
||
}
|
||
|
||
// DeleteAnnouncementParams 删除群公告参数
|
||
type DeleteAnnouncementParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
AnnouncementID string `json:"announcement_id"` // 公告ID
|
||
}
|
||
|
||
// DissolveGroupParams 解散群组参数
|
||
type DissolveGroupParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
}
|
||
|
||
// GetMyMemberInfoParams 获取我在群组中的成员信息参数
|
||
type GetMyMemberInfoParams struct {
|
||
GroupID string `json:"group_id"` // 群组ID
|
||
}
|
||
|
||
// ==================== Vote DTOs ====================
|
||
|
||
// CreateVotePostRequest 创建投票帖子请求
|
||
type CreateVotePostRequest struct {
|
||
Title string `json:"title" binding:"required,max=200"`
|
||
Content string `json:"content" binding:"max=2000"`
|
||
ChannelID *string `json:"channel_id,omitempty"`
|
||
Images []string `json:"images"`
|
||
VoteOptions []string `json:"vote_options" binding:"required,min=2,max=10"` // 投票选项,至少2个最多10个
|
||
}
|
||
|
||
// VoteOptionDTO 投票选项DTO
|
||
type VoteOptionDTO struct {
|
||
ID string `json:"id"`
|
||
Content string `json:"content"`
|
||
VotesCount int `json:"votes_count"`
|
||
}
|
||
|
||
// VoteResultDTO 投票结果DTO
|
||
type VoteResultDTO struct {
|
||
Options []VoteOptionDTO `json:"options"`
|
||
TotalVotes int `json:"total_votes"`
|
||
HasVoted bool `json:"has_voted"`
|
||
VotedOptionID string `json:"voted_option_id,omitzero"`
|
||
}
|
||
|
||
// ==================== WebSocket Response DTOs ====================
|
||
|
||
// WSResponse WebSocket响应结构体
|
||
type WSResponse struct {
|
||
Success bool `json:"success"` // 是否成功
|
||
Action string `json:"action"` // 响应原action
|
||
Data interface{} `json:"data,omitempty"` // 响应数据
|
||
Error string `json:"error,omitempty"` // 错误信息
|
||
}
|
||
|
||
// ==================== Admin Post DTOs ====================
|
||
|
||
// AdminPostListResponse 管理端帖子列表响应
|
||
type AdminPostListResponse struct {
|
||
ID string `json:"id"`
|
||
UserID string `json:"user_id"`
|
||
Title string `json:"title"`
|
||
Content string `json:"content"`
|
||
Images []PostImageResponse `json:"images"`
|
||
Status string `json:"status"`
|
||
LikesCount int `json:"likes_count,omitzero"`
|
||
CommentsCount int `json:"comments_count,omitzero"`
|
||
FavoritesCount int `json:"favorites_count,omitzero"`
|
||
ViewsCount int `json:"views_count,omitzero"`
|
||
IsPinned bool `json:"is_pinned"`
|
||
IsFeatured bool `json:"is_featured"`
|
||
IsLocked bool `json:"is_locked"`
|
||
RejectReason string `json:"reject_reason,omitempty"`
|
||
ReviewedAt string `json:"reviewed_at,omitempty"`
|
||
ReviewedBy string `json:"reviewed_by,omitempty"`
|
||
CreatedAt string `json:"created_at"`
|
||
UpdatedAt string `json:"updated_at"`
|
||
ContentEditedAt string `json:"content_edited_at,omitempty"`
|
||
Author *UserResponse `json:"author"`
|
||
}
|
||
|
||
// AdminPostDetailResponse 管理端帖子详情响应
|
||
type AdminPostDetailResponse struct {
|
||
ID string `json:"id"`
|
||
UserID string `json:"user_id"`
|
||
ChannelID *string `json:"channel_id,omitempty"`
|
||
Title string `json:"title"`
|
||
Content string `json:"content"`
|
||
Images []PostImageResponse `json:"images"`
|
||
Status string `json:"status"`
|
||
LikesCount int `json:"likes_count,omitzero"`
|
||
CommentsCount int `json:"comments_count,omitzero"`
|
||
FavoritesCount int `json:"favorites_count,omitzero"`
|
||
SharesCount int `json:"shares_count,omitzero"`
|
||
ViewsCount int `json:"views_count,omitzero"`
|
||
IsPinned bool `json:"is_pinned"`
|
||
IsFeatured bool `json:"is_featured"`
|
||
IsLocked bool `json:"is_locked"`
|
||
IsVote bool `json:"is_vote"`
|
||
RejectReason string `json:"reject_reason,omitempty"`
|
||
ReviewedAt string `json:"reviewed_at,omitempty"`
|
||
ReviewedBy string `json:"reviewed_by,omitempty"`
|
||
CreatedAt string `json:"created_at"`
|
||
UpdatedAt string `json:"updated_at"`
|
||
ContentEditedAt string `json:"content_edited_at,omitempty"`
|
||
Author *UserResponse `json:"author"`
|
||
}
|
||
|
||
// AdminModeratePostRequest 审核帖子请求
|
||
type AdminModeratePostRequest struct {
|
||
Status string `json:"status" binding:"required,oneof=published rejected"`
|
||
Reason string `json:"reason"` // 拒绝理由(当status为rejected时)
|
||
}
|
||
|
||
// AdminBatchDeletePostsRequest 批量删除帖子请求
|
||
type AdminBatchDeletePostsRequest struct {
|
||
IDs []string `json:"ids" binding:"required,min=1"`
|
||
}
|
||
|
||
// AdminBatchModeratePostsRequest 批量审核帖子请求
|
||
type AdminBatchModeratePostsRequest struct {
|
||
IDs []string `json:"ids" binding:"required,min=1"`
|
||
Status string `json:"status" binding:"required,oneof=published rejected"`
|
||
}
|
||
|
||
// AdminSetPostPinRequest 置顶帖子请求
|
||
type AdminSetPostPinRequest struct {
|
||
IsPinned bool `json:"is_pinned"`
|
||
}
|
||
|
||
// AdminSetPostFeatureRequest 加精帖子请求
|
||
type AdminSetPostFeatureRequest struct {
|
||
IsFeatured bool `json:"is_featured"`
|
||
}
|
||
|
||
// AdminBatchOperationResponse 批量操作响应
|
||
type AdminBatchOperationResponse struct {
|
||
Success bool `json:"success"`
|
||
Message string `json:"message"`
|
||
Failed []string `json:"failed,omitempty"` // 失败的ID列表
|
||
}
|
||
|
||
// ==================== Admin Comment DTOs ====================
|
||
|
||
// AdminCommentListResponse 管理端评论列表响应
|
||
type AdminCommentListResponse struct {
|
||
ID string `json:"id"`
|
||
PostID string `json:"post_id"`
|
||
UserID string `json:"user_id"`
|
||
ParentID *string `json:"parent_id"`
|
||
RootID *string `json:"root_id"`
|
||
Content string `json:"content"`
|
||
Images []CommentImageResponse `json:"images"`
|
||
Status string `json:"status"`
|
||
LikesCount int `json:"likes_count"`
|
||
RepliesCount int `json:"replies_count"`
|
||
CreatedAt string `json:"created_at"`
|
||
UpdatedAt string `json:"updated_at"`
|
||
Author *UserResponse `json:"author"`
|
||
Post *AdminCommentPostInfo `json:"post"`
|
||
}
|
||
|
||
// AdminCommentPostInfo 评论关联的帖子简要信息
|
||
type AdminCommentPostInfo struct {
|
||
ID string `json:"id"`
|
||
Title string `json:"title"`
|
||
}
|
||
|
||
// AdminCommentDetailResponse 管理端评论详情响应
|
||
type AdminCommentDetailResponse struct {
|
||
ID string `json:"id"`
|
||
PostID string `json:"post_id"`
|
||
UserID string `json:"user_id"`
|
||
ParentID *string `json:"parent_id"`
|
||
RootID *string `json:"root_id"`
|
||
Content string `json:"content"`
|
||
Images []CommentImageResponse `json:"images"`
|
||
Status string `json:"status"`
|
||
LikesCount int `json:"likes_count"`
|
||
RepliesCount int `json:"replies_count"`
|
||
CreatedAt string `json:"created_at"`
|
||
UpdatedAt string `json:"updated_at"`
|
||
Author *UserResponse `json:"author"`
|
||
Post *AdminCommentPostInfo `json:"post"`
|
||
ReplyToUser *UserResponse `json:"reply_to_user,omitempty"` // 被回复的用户信息
|
||
}
|
||
|
||
// AdminBatchDeleteCommentsRequest 批量删除评论请求
|
||
type AdminBatchDeleteCommentsRequest struct {
|
||
IDs []string `json:"ids" binding:"required,min=1"`
|
||
}
|
||
|
||
// ==================== Admin Group DTOs ====================
|
||
|
||
// AdminGroupListResponse 管理端群组列表响应
|
||
type AdminGroupListResponse struct {
|
||
ID string `json:"id"`
|
||
Name string `json:"name"`
|
||
Avatar string `json:"avatar"`
|
||
Description string `json:"description"`
|
||
OwnerID string `json:"owner_id"`
|
||
Owner *UserResponse `json:"owner"`
|
||
MemberCount int `json:"member_count"`
|
||
MaxMembers int `json:"max_members"`
|
||
JoinType int `json:"join_type"`
|
||
MuteAll bool `json:"mute_all"`
|
||
Status string `json:"status"`
|
||
PostCount int64 `json:"post_count"`
|
||
CreatedAt string `json:"created_at"`
|
||
UpdatedAt string `json:"updated_at"`
|
||
}
|
||
|
||
// AdminGroupDetailResponse 管理端群组详情响应
|
||
type AdminGroupDetailResponse struct {
|
||
ID string `json:"id"`
|
||
Name string `json:"name"`
|
||
Avatar string `json:"avatar"`
|
||
Description string `json:"description"`
|
||
OwnerID string `json:"owner_id"`
|
||
Owner *UserResponse `json:"owner"`
|
||
MemberCount int `json:"member_count"`
|
||
MaxMembers int `json:"max_members"`
|
||
JoinType int `json:"join_type"`
|
||
MuteAll bool `json:"mute_all"`
|
||
Status string `json:"status"`
|
||
PostCount int64 `json:"post_count"`
|
||
Announcement *GroupAnnouncementResponse `json:"announcement,omitempty"`
|
||
IsPublic bool `json:"is_public"`
|
||
CreatedAt string `json:"created_at"`
|
||
UpdatedAt string `json:"updated_at"`
|
||
}
|
||
|
||
// AdminGroupMemberResponse 管理端群组成员响应
|
||
type AdminGroupMemberResponse struct {
|
||
ID string `json:"id"`
|
||
UserID string `json:"user_id"`
|
||
Username string `json:"username"`
|
||
Nickname string `json:"nickname"`
|
||
Avatar string `json:"avatar"`
|
||
Role string `json:"role"`
|
||
Muted bool `json:"muted"`
|
||
JoinedAt string `json:"joined_at"`
|
||
User *UserResponse `json:"user,omitempty"`
|
||
}
|
||
|
||
// AdminGroupMemberListResponse 管理端群组成员列表响应
|
||
type AdminGroupMemberListResponse struct {
|
||
List []*AdminGroupMemberResponse `json:"list"`
|
||
Total int64 `json:"total"`
|
||
Page int `json:"page"`
|
||
PageSize int `json:"page_size"`
|
||
}
|
||
|
||
// AdminUpdateGroupStatusRequest 更新群组状态请求
|
||
type AdminUpdateGroupStatusRequest struct {
|
||
Status string `json:"status" binding:"required,oneof=active dissolved"`
|
||
}
|
||
|
||
// AdminTransferGroupOwnerRequest 转让群主请求
|
||
type AdminTransferGroupOwnerRequest struct {
|
||
NewOwnerID string `json:"new_owner_id" binding:"required"`
|
||
}
|
||
|
||
// ==================== Admin Dashboard DTOs ====================
|
||
|
||
// DashboardStatsResponse 仪表盘统计数据响应
|
||
type DashboardStatsResponse struct {
|
||
TotalUsers int64 `json:"total_users"` // 总用户数
|
||
TodayNewUsers int64 `json:"today_new_users"` // 今日新增用户
|
||
ActiveUsersToday int64 `json:"active_users_today"` // 今日活跃用户 (DAU)
|
||
ActiveUsersWeek int64 `json:"active_users_week"` // 本周活跃用户 (WAU)
|
||
ActiveUsersMonth int64 `json:"active_users_month"` // 本月活跃用户 (MAU)
|
||
Retention1Day int64 `json:"retention_1_day"` // 次日留存率 (百分比 0-100)
|
||
Retention7Day int64 `json:"retention_7_day"` // 7日留存率 (百分比 0-100)
|
||
Retention30Day int64 `json:"retention_30_day"` // 30日留存率 (百分比 0-100)
|
||
TotalPosts int64 `json:"total_posts"` // 总帖子数
|
||
TodayPosts int64 `json:"today_posts"` // 今日帖子数
|
||
PendingPosts int64 `json:"pending_posts"` // 待审核帖子数
|
||
TotalComments int64 `json:"total_comments"` // 总评论数
|
||
TodayComments int64 `json:"today_comments"` // 今日评论数
|
||
TotalGroups int64 `json:"total_groups"` // 总群组数
|
||
TodayNewGroups int64 `json:"today_new_groups"` // 今日新建群组
|
||
PendingReview int64 `json:"pending_review"` // 待审核总数
|
||
PendingPostsCount int64 `json:"pending_posts_count"` // 待审核帖子数
|
||
PendingComments int64 `json:"pending_comments_count"` // 待审核评论数
|
||
}
|
||
|
||
// UserActivityTrendResponse 用户活跃度趋势响应
|
||
type UserActivityTrendResponse struct {
|
||
Date string `json:"date"` // 日期
|
||
NewUsers int64 `json:"new_users"` // 新增用户数
|
||
ActiveUsers int64 `json:"active_users"` // 活跃用户数
|
||
Posts int64 `json:"posts"` // 帖子数
|
||
Comments int64 `json:"comments"` // 评论数
|
||
}
|
||
|
||
// ContentStatsResponse 内容统计响应
|
||
type ContentStatsResponse struct {
|
||
ContentDistribution []ContentDistributionItem `json:"content_distribution"` // 内容分布
|
||
PostStatusDistribution []PostStatusDistributionItem `json:"post_status_distribution"` // 帖子状态分布
|
||
UserGrowth []UserGrowthItem `json:"user_growth"` // 用户增长趋势
|
||
}
|
||
|
||
// ContentDistributionItem 内容分布项
|
||
type ContentDistributionItem struct {
|
||
Type string `json:"type"` // 类型:posts, comments, groups
|
||
Name string `json:"name"` // 名称
|
||
Count int64 `json:"count"` // 数量
|
||
}
|
||
|
||
// PostStatusDistributionItem 帖子状态分布项
|
||
type PostStatusDistributionItem struct {
|
||
Status string `json:"status"` // 状态
|
||
Name string `json:"name"` // 名称
|
||
Count int64 `json:"count"` // 数量
|
||
}
|
||
|
||
// UserGrowthItem 用户增长项
|
||
type UserGrowthItem struct {
|
||
Date string `json:"date"` // 日期
|
||
NewUsers int64 `json:"new_users"` // 新增用户数
|
||
}
|
||
|
||
// PendingContentResponse 待审核内容响应
|
||
type PendingContentResponse struct {
|
||
ID string `json:"id"` // 内容ID
|
||
Type string `json:"type"` // 内容类型(post/comment)
|
||
Title string `json:"title"` // 标题(帖子有,评论可能为空)
|
||
Content string `json:"content"` // 内容
|
||
Author *PendingContentAuthor `json:"author"` // 作者信息
|
||
CreatedAt string `json:"created_at"` // 创建时间
|
||
}
|
||
|
||
// PendingContentAuthor 待审核内容作者信息
|
||
type PendingContentAuthor struct {
|
||
ID string `json:"id"` // 用户ID
|
||
Username string `json:"username"` // 用户名
|
||
Nickname string `json:"nickname"` // 昵称
|
||
Avatar string `json:"avatar"` // 头像
|
||
}
|
||
|
||
// OnlineUsersResponse 在线用户数响应
|
||
type OnlineUsersResponse struct {
|
||
Count int64 `json:"count"` // 在线用户数
|
||
}
|
||
|
||
// ==================== Cursor Pagination DTOs ====================
|
||
|
||
// CursorPageRequest 游标分页请求
|
||
type CursorPageRequest struct {
|
||
Cursor string `json:"cursor" form:"cursor"` // 游标(首次请求为空)
|
||
Direction string `json:"direction" form:"direction"` // forward | backward
|
||
PageSize int `json:"page_size" form:"page_size"` // 每页数量
|
||
}
|
||
|
||
// CursorPageResponse 游标分页响应(泛型版本)
|
||
// 注意:由于 Go 的限制,这里使用 interface{} 作为 Items 类型
|
||
// 实际使用时可以创建特定类型的响应结构体
|
||
type CursorPageResponse struct {
|
||
Items interface{} `json:"list"`
|
||
NextCursor string `json:"next_cursor,omitempty"` // 下一页游标
|
||
PrevCursor string `json:"prev_cursor,omitempty"` // 上一页游标(可选)
|
||
HasMore bool `json:"has_more"` // 是否有更多数据
|
||
}
|
||
|
||
// CursorPageMeta 分页元信息
|
||
type CursorPageMeta struct {
|
||
PageSize int `json:"page_size"`
|
||
Direction string `json:"direction"`
|
||
}
|
||
|
||
// PostCursorPageResponse 帖子游标分页响应
|
||
type PostCursorPageResponse struct {
|
||
Items []*PostResponse `json:"list"`
|
||
NextCursor string `json:"next_cursor,omitempty"`
|
||
PrevCursor string `json:"prev_cursor,omitempty"`
|
||
HasMore bool `json:"has_more"`
|
||
}
|
||
|
||
// CommentCursorPageResponse 评论游标分页响应
|
||
type CommentCursorPageResponse struct {
|
||
Items []*CommentResponse `json:"list"`
|
||
NextCursor string `json:"next_cursor,omitempty"`
|
||
PrevCursor string `json:"prev_cursor,omitempty"`
|
||
HasMore bool `json:"has_more"`
|
||
}
|
||
|
||
// MessageCursorPageResponse 消息游标分页响应
|
||
type MessageCursorPageResponse struct {
|
||
Items []*MessageResponse `json:"list"`
|
||
NextCursor string `json:"next_cursor,omitempty"`
|
||
PrevCursor string `json:"prev_cursor,omitempty"`
|
||
HasMore bool `json:"has_more"`
|
||
}
|
||
|
||
// ConversationCursorPageResponse 会话游标分页响应
|
||
type ConversationCursorPageResponse struct {
|
||
Items []*ConversationResponse `json:"list"`
|
||
NextCursor string `json:"next_cursor,omitempty"`
|
||
PrevCursor string `json:"prev_cursor,omitempty"`
|
||
HasMore bool `json:"has_more"`
|
||
}
|
||
|
||
// GroupCursorPageResponse 群组游标分页响应
|
||
type GroupCursorPageResponse struct {
|
||
Items []*GroupResponse `json:"list"`
|
||
NextCursor string `json:"next_cursor,omitempty"`
|
||
PrevCursor string `json:"prev_cursor,omitempty"`
|
||
HasMore bool `json:"has_more"`
|
||
}
|
||
|
||
// NotificationCursorPageResponse 通知游标分页响应
|
||
type NotificationCursorPageResponse struct {
|
||
Items []*NotificationResponse `json:"list"`
|
||
NextCursor string `json:"next_cursor,omitempty"`
|
||
PrevCursor string `json:"prev_cursor,omitempty"`
|
||
HasMore bool `json:"has_more"`
|
||
}
|
||
|
||
// GroupMemberCursorPageResponse 群成员游标分页响应
|
||
type GroupMemberCursorPageResponse struct {
|
||
Items []*GroupMemberResponse `json:"list"`
|
||
NextCursor string `json:"next_cursor,omitempty"`
|
||
PrevCursor string `json:"prev_cursor,omitempty"`
|
||
HasMore bool `json:"has_more"`
|
||
}
|
||
|
||
// GroupAnnouncementCursorPageResponse 群公告游标分页响应
|
||
type GroupAnnouncementCursorPageResponse struct {
|
||
Items []*GroupAnnouncementResponse `json:"list"`
|
||
NextCursor string `json:"next_cursor,omitempty"`
|
||
PrevCursor string `json:"prev_cursor,omitempty"`
|
||
HasMore bool `json:"has_more"`
|
||
}
|