Files
EchoChat/backend/go-service/app/dto/admin_dto.go
bujinyuan c8ae70ef97 fix(phase2a): handleError 增强 + 代码格式化 + 测试报告归档
- auth/contact Controller handleError 增加 fallbackMsg 可变参数,未知错误可返回更有语义的降级提示
- import 排序、变量对齐等 gofmt 格式规范化
- 新增管理端测试报告和路由验证报告

Made-with: Cursor
2026-03-03 09:51:43 +08:00

62 lines
3.2 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
}