Files
EchoChat/backend/go-service/app/dto/admin_dto.go
2026-05-18 19:42:55 +08:00

239 lines
12 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Package dto 定义数据传输对象
package dto
// UserListRequest 管理端用户列表查询请求参数
type UserListRequest struct {
Page int `form:"page" binding:"required,min=1"` // 页码,从 1 开始
PageSize int `form:"page_size" binding:"required,min=1,max=100"` // 每页数量1-100
Keyword string `form:"keyword"` // 搜索关键词(匹配用户名或邮箱)
Status *int `form:"status"` // 状态筛选1=正常, 2=禁用, 3=注销;为空则不筛选
}
// UserListResponse 管理端用户列表响应
type UserListResponse struct {
Total int64 `json:"total"` // 符合条件的用户总数
List []AdminUserInfo `json:"list"` // 当前页的用户列表
}
// AdminUserInfo 管理端用户信息(比 UserInfo 更详细,包含管理字段)
type AdminUserInfo struct {
ID int64 `json:"id"` // 用户 ID
Username string `json:"username"` // 用户名
Email string `json:"email"` // 邮箱
Nickname string `json:"nickname"` // 昵称
Avatar string `json:"avatar"` // 头像 URL
Gender int `json:"gender"` // 性别0=未知, 1=男, 2=女
Phone string `json:"phone,omitempty"` // 手机号
Status int `json:"status"` // 账号状态
StatusText string `json:"status_text"` // 状态中文描述
Roles []RoleInfo `json:"roles"` // 角色详情列表(含 code/name/level
MaxLevel int `json:"max_level"` // 用户最高权限等级(最小 level 值)
LastLoginAt string `json:"last_login_at,omitempty"` // 最后登录时间
LastLoginIP string `json:"last_login_ip,omitempty"` // 最后登录 IP
CreatedAt string `json:"created_at"` // 注册时间
UpdatedAt string `json:"updated_at"` // 更新时间
}
// RoleInfo 角色信息(用于前端角色列表展示和角色分配)
type RoleInfo struct {
Code string `json:"code"` // 角色代码
Name string `json:"name"` // 角色中文名称
Level int `json:"level"` // 角色等级,值越小权限越高
}
// UpdateUserStatusRequest 更新用户状态请求
type UpdateUserStatusRequest struct {
Status int `json:"status" binding:"required,oneof=1 2"` // 目标状态1=正常, 2=禁用
}
// SetRolesRequest 批量设置用户角色请求(替换原有的单角色分配)
type SetRolesRequest struct {
RoleCodes []string `json:"role_codes" binding:"required,min=1"` // 角色代码列表
}
// AdminCreateUserRequest 管理员手动创建用户请求
type AdminCreateUserRequest struct {
Username string `json:"username" binding:"required,min=3,max=50"` // 用户名
Email string `json:"email" binding:"required,email"` // 邮箱
Password string `json:"password" binding:"required,min=6,max=50"` // 初始密码
Nickname string `json:"nickname" binding:"max=50"` // 昵称(选填)
RoleCode string `json:"role_code" binding:"omitempty"` // 初始角色(选填,默认 user
}
// ====== 管理端消息管理 DTO ======
// AdminMessageListRequest 管理端消息列表查询请求
type AdminMessageListRequest struct {
Keyword string `form:"keyword"` // 搜索关键词(模糊匹配消息内容)
Type *int `form:"type"` // 消息类型筛选1/2/3/5/10
SenderID *int64 `form:"sender_id"` // 发送者 ID
ConversationID *int64 `form:"conversation_id"` // 会话 ID
Status *int `form:"status"` // 消息状态1=正常/2=已撤回/3=已删除)
StartTime string `form:"start_time"` // 开始时间YYYY-MM-DD
EndTime string `form:"end_time"` // 结束时间YYYY-MM-DD
Page int `form:"page"` // 页码默认1
PageSize int `form:"page_size"` // 每页条数默认20
}
// AdminMessageListResponse 管理端消息列表响应
type AdminMessageListResponse struct {
Total int64 `json:"total"` // 总条数
List []AdminMessageDTO `json:"list"` // 消息列表
Page int `json:"page"` // 当前页码
PageSize int `json:"page_size"` // 每页条数
}
// AdminMessageDTO 管理端消息条目
type AdminMessageDTO struct {
ID int64 `json:"id"` // 消息 ID
ConversationID int64 `json:"conversation_id"` // 会话 ID
SenderID int64 `json:"sender_id"` // 发送者 ID
SenderNickname string `json:"sender_nickname"` // 发送者昵称
SenderAvatar string `json:"sender_avatar"` // 发送者头像
Type int `json:"type"` // 消息类型
TypeLabel string `json:"type_label"` // 类型中文标签
Content string `json:"content"` // 消息内容
Extra *string `json:"extra,omitempty"` // 扩展数据 JSON
Status int `json:"status"` // 消息状态
StatusLabel string `json:"status_label"` // 状态中文标签
CreatedAt string `json:"created_at"` // 发送时间
}
// AdminMessageStatsRequest 管理端消息统计请求
type AdminMessageStatsRequest struct {
Days int `form:"days"` // 统计天数默认7最大90
}
// AdminMessageStatsResponse 管理端消息统计响应
type AdminMessageStatsResponse struct {
TotalCount int64 `json:"total_count"` // 消息总数
TodayCount int64 `json:"today_count"` // 今日消息数
TypeDistribution []TypeDistItem `json:"type_distribution"` // 类型分布
DailyTrend []DailyTrendItem `json:"daily_trend"` // 每日趋势
ActiveUsers []ActiveUserItem `json:"active_users"` // 活跃用户排行
ActiveGroups []ActiveGroupItem `json:"active_groups"` // 活跃群组排行
}
// TypeDistItem 消息类型分布条目
type TypeDistItem struct {
Type int `json:"type"` // 消息类型
Label string `json:"label"` // 类型中文标签
Count int64 `json:"count"` // 数量
}
// DailyTrendItem 每日消息趋势条目
type DailyTrendItem struct {
Date string `json:"date"` // 日期YYYY-MM-DD
Count int64 `json:"count"` // 数量
}
// ActiveUserItem 活跃用户排行条目
type ActiveUserItem struct {
UserID int64 `json:"user_id"` // 用户 ID
Nickname string `json:"nickname"` // 昵称
Count int64 `json:"count"` // 消息数
}
// ActiveGroupItem 活跃群组排行条目
type ActiveGroupItem struct {
GroupID int64 `json:"group_id"` // 群组 ID
Name string `json:"name"` // 群名称
Count int64 `json:"count"` // 消息数
}
// ====== 管理端会议管理 DTOPhase B 扩展) ======
// AdminMeetingListRequest 管理端会议列表查询请求
//
// 与消息列表保持一致的分页/筛选风格:
// - Keyword模糊匹配 title 或 room_code方便客服按客户描述定位
// - Status0=未开始 / 1=进行中 / 2=已结束(与 meeting_rooms.status 一一对应)
// - HasRecordingtrue=仅返回有录制记录的会议,便于"录制审计"场景
// - StartTime / EndTime按 created_at 过滤YYYY-MM-DD 闭区间
type AdminMeetingListRequest struct {
Keyword string `form:"keyword"` // 模糊匹配 title / room_code
Status *int `form:"status"` // 0=未开始 1=进行中 2=已结束
HostID *int64 `form:"host_id"` // 主持人 ID 精确匹配
HasRecording *bool `form:"has_recording"` // true=仅含录制的会议
StartTime string `form:"start_time"` // YYYY-MM-DD
EndTime string `form:"end_time"` // YYYY-MM-DD
Page int `form:"page"`
PageSize int `form:"page_size"`
}
// AdminMeetingDTO 管理端会议条目(列表行)
//
// 字段选择原则:
// - 列表场景:会议号 / 标题 / 主持人 / 状态 / 时间 / 参与人数 / 录制数
// - 详情字段(参与者明细、录制列表)放到 GetMeetingDetail 单独返回,避免列表过宽
type AdminMeetingDTO struct {
ID int64 `json:"id"`
RoomCode string `json:"room_code"`
Title string `json:"title"`
Type int `json:"type"` // 1=即时 2=预约
TypeLabel string `json:"type_label"` // "即时会议" / "预约会议"
Status int `json:"status"` // 0/1/2
StatusLabel string `json:"status_label"` // "未开始" / "进行中" / "已结束"
HostID int64 `json:"host_id"`
HostNickname string `json:"host_nickname"`
HostAvatar string `json:"host_avatar"`
MaxMembers int `json:"max_members"`
ParticipantCount int `json:"participant_count"` // 历史累计入会人数(去重)
RecordingCount int `json:"recording_count"` // 该会议的录制条数
DurationSec int `json:"duration_sec"` // 会议时长(秒);结束前用 now-started_at结束后用 ended_at-started_at
ScheduledAt string `json:"scheduled_at"` // 预约会议开始时间,空表示即时会议
StartedAt string `json:"started_at"` // 实际开始
EndedAt string `json:"ended_at"` // 实际结束
EndedReason string `json:"ended_reason"` // host_ended / empty_ttl / admin_force / system_error
CreatedAt string `json:"created_at"`
}
// AdminMeetingListResponse 管理端会议列表响应(含统计摘要)
type AdminMeetingListResponse struct {
Total int64 `json:"total"`
List []AdminMeetingDTO `json:"list"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}
// AdminMeetingParticipantDTO 会议详情中的参与者条目
type AdminMeetingParticipantDTO struct {
UserID int64 `json:"user_id"`
Nickname string `json:"nickname"`
Avatar string `json:"avatar"`
Role int `json:"role"` // 0=普通 1=主持人 2=联合主持人
RoleLabel string `json:"role_label"`
JoinedAt string `json:"joined_at"`
LeftAt string `json:"left_at"` // 空表示仍在会议中
LeftReason string `json:"left_reason"` // self / kicked / host_end / empty_ttl / disconnect
Duration int `json:"duration"` // 秒
}
// AdminMeetingRecordingDTO 会议详情中的录制条目
type AdminMeetingRecordingDTO struct {
ID int64 `json:"id"`
StartedBy int64 `json:"started_by"`
Status string `json:"status"` // recording / uploading / ready / failed
FileURL string `json:"file_url"`
SizeBytes int64 `json:"size_bytes"`
DurationSec int `json:"duration_sec"`
FailureReason string `json:"failure_reason"` // 仅 failed 时返回
StartedAt string `json:"started_at"`
StoppedAt string `json:"stopped_at"`
}
// AdminMeetingDetailResponse 会议详情(含参与者列表 + 录制列表)
type AdminMeetingDetailResponse struct {
AdminMeetingDTO
Participants []AdminMeetingParticipantDTO `json:"participants"`
Recordings []AdminMeetingRecordingDTO `json:"recordings"`
}
// AdminMeetingStatsResponse 会议管理摘要统计(顶栏卡片)
type AdminMeetingStatsResponse struct {
TotalCount int64 `json:"total_count"` // 历史会议总数
ActiveCount int64 `json:"active_count"` // 当前进行中
TodayCount int64 `json:"today_count"` // 今日创建的会议
RecordingCount int64 `json:"recording_count"` // 录制总数
}