Initial backend repository commit.

Set up project files and add .gitignore to exclude local build/runtime artifacts.

Made-with: Cursor
This commit is contained in:
2026-03-09 21:28:58 +08:00
commit 4d8f2ec997
102 changed files with 25022 additions and 0 deletions

819
internal/dto/dto.go Normal file
View File

@@ -0,0 +1,819 @@
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"`
Email *string `json:"email,omitempty"`
Phone *string `json:"phone,omitempty"`
EmailVerified bool `json:"email_verified"`
Avatar string `json:"avatar"`
CoverURL string `json:"cover_url"` // 头图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"`
}
// UserDetailResponse 用户详情响应
type UserDetailResponse struct {
ID string `json:"id"`
Username string `json:"username"`
Nickname string `json:"nickname"`
Email *string `json:"email"`
EmailVerified bool `json:"email_verified"`
Phone *string `json:"phone,omitempty"` // 仅当前用户自己可见
Avatar string `json:"avatar"`
CoverURL string `json:"cover_url"` // 头图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"`
}
// ==================== Post DTOs ====================
// PostImageResponse 帖子图片响应
type PostImageResponse struct {
ID string `json:"id"`
URL string `json:"url"`
ThumbnailURL string `json:"thumbnail_url"`
Width int `json:"width"`
Height int `json:"height"`
}
// PostResponse 帖子响应(列表用)
type PostResponse struct {
ID string `json:"id"`
UserID string `json:"user_id"`
Title string `json:"title"`
Content string `json:"content"`
Images []PostImageResponse `json:"images"`
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"`
Author *UserResponse `json:"author"`
IsLiked bool `json:"is_liked"`
IsFavorited bool `json:"is_favorited"`
}
// PostDetailResponse 帖子详情响应
type PostDetailResponse 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"`
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"`
Author *UserResponse `json:"author"`
IsLiked bool `json:"is_liked"`
IsFavorited bool `json:"is_favorited"`
}
// ==================== 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,omitempty"`
Height int `json:"height,omitempty"`
ThumbnailURL string `json:"thumbnail_url,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
}
// VoiceSegmentData 语音数据
type VoiceSegmentData struct {
URL string `json:"url"`
Duration int `json:"duration,omitempty"` // 秒
FileSize int64 `json:"file_size,omitempty"`
}
// VideoSegmentData 视频数据
type VideoSegmentData struct {
URL string `json:"url"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Duration int `json:"duration,omitempty"` // 秒
ThumbnailURL string `json:"thumbnail_url,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
}
// FileSegmentData 文件数据
type FileSegmentData struct {
URL string `json:"url"`
Name string `json:"name"`
Size int64 `json:"size,omitempty"`
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"`
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,omitempty"`
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"`
PushedAt time.Time `json:"pushed_at,omitempty"`
DeliveredAt time.Time `json:"delivered_at,omitempty"`
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"`
}
// ==================== 时间格式化 ====================
// 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"`
CommunityID string `json:"community_id"`
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,omitempty"`
}
// ==================== 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"` // 错误信息
}