初始化
This commit is contained in:
148
api/user/v1/user.go
Normal file
148
api/user/v1/user.go
Normal file
@@ -0,0 +1,148 @@
|
||||
package v1
|
||||
|
||||
import "github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
// ===== 公共结构 =====
|
||||
|
||||
type UserInfo struct {
|
||||
Id int64 `json:"id"`
|
||||
Nickname string `json:"nickname"`
|
||||
AvatarUrl string `json:"avatar_url"`
|
||||
}
|
||||
|
||||
type LevelInfo struct {
|
||||
LevelKey string `json:"level_key"`
|
||||
Name string `json:"name"`
|
||||
Modules []string `json:"modules"`
|
||||
}
|
||||
|
||||
// ===== 登录 =====
|
||||
|
||||
type WxLoginReq struct {
|
||||
g.Meta `path:"/user/wx-login" method:"post" tags:"user" summary:"微信登录"`
|
||||
Code string `v:"required#code不能为空" json:"code"`
|
||||
}
|
||||
type WxLoginRes struct {
|
||||
Token string `json:"token"`
|
||||
User *UserInfo `json:"user"`
|
||||
Level *LevelInfo `json:"level"`
|
||||
}
|
||||
|
||||
// DevLogin 仅 debug 配置开启时可用(H5/联调)
|
||||
type DevLoginReq struct {
|
||||
g.Meta `path:"/user/dev-login" method:"post" tags:"user" summary:"开发登录"`
|
||||
}
|
||||
type DevLoginRes = WxLoginRes
|
||||
|
||||
// ===== H5 账号注册/登录 =====
|
||||
|
||||
// Register H5 独立账号注册(注册即登录)
|
||||
type RegisterReq struct {
|
||||
g.Meta `path:"/user/register" method:"post" tags:"user" summary:"H5 账号注册"`
|
||||
Username string `v:"required|length:3,32#用户名不能为空|用户名长度为 3-32 位" json:"username"`
|
||||
Password string `v:"required|length:6,64#密码不能为空|密码长度为 6-64 位" json:"password"`
|
||||
Nickname string `v:"length:0,32#昵称最长 32 位" json:"nickname"`
|
||||
}
|
||||
type RegisterRes = WxLoginRes
|
||||
|
||||
// AccountLogin H5 账号密码登录
|
||||
type AccountLoginReq struct {
|
||||
g.Meta `path:"/user/login" method:"post" tags:"user" summary:"H5 账号登录"`
|
||||
Username string `v:"required#用户名不能为空" json:"username"`
|
||||
Password string `v:"required#密码不能为空" json:"password"`
|
||||
}
|
||||
type AccountLoginRes = WxLoginRes
|
||||
|
||||
// BindAccount 将一个 H5 独立账号合并进当前登录账号(两端共享数据)
|
||||
type BindAccountReq struct {
|
||||
g.Meta `path:"/user/bind-account" method:"post" tags:"user" summary:"绑定(合并)H5 账号"`
|
||||
Username string `v:"required#用户名不能为空" json:"username"`
|
||||
Password string `v:"required#密码不能为空" json:"password"`
|
||||
}
|
||||
type BindAccountRes struct {
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
// ===== 个人信息 =====
|
||||
|
||||
// ProfileUpdate 更新昵称 / 头像(avatarUrl 支持远端 URL 或预置头像 key:avatar:rocket 等)
|
||||
type ProfileUpdateReq struct {
|
||||
g.Meta `path:"/user/profile" method:"put" tags:"user" summary:"更新个人信息"`
|
||||
Nickname string `v:"required|length:1,32#昵称不能为空|昵称最长 32 位" json:"nickname"`
|
||||
AvatarUrl string `v:"length:0,512" json:"avatar_url"`
|
||||
}
|
||||
type ProfileUpdateRes struct {
|
||||
Nickname string `json:"nickname"`
|
||||
AvatarUrl string `json:"avatar_url"`
|
||||
}
|
||||
|
||||
// ===== 等级 =====
|
||||
|
||||
type LevelReq struct {
|
||||
g.Meta `path:"/user/level" method:"get" tags:"user" summary:"我的等级与模块"`
|
||||
}
|
||||
type LevelRes = LevelInfo
|
||||
|
||||
// UserInfoGet 当前登录用户信息(token 校验后恢复 user 用)
|
||||
type UserInfoGetReq struct {
|
||||
g.Meta `path:"/user/info" method:"get" tags:"user" summary:"我的信息"`
|
||||
}
|
||||
type UserInfoGetRes = UserInfo
|
||||
|
||||
// ===== 工具目录 =====
|
||||
|
||||
type ModuleOut struct {
|
||||
ModuleKey string `json:"module_key"`
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon"`
|
||||
Locked bool `json:"locked"`
|
||||
EnabledToolsCount int `json:"enabled_tools_count"`
|
||||
}
|
||||
|
||||
type ToolOut struct {
|
||||
ToolKey string `json:"tool_key"`
|
||||
ModuleKey string `json:"module_key"`
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon"`
|
||||
Description string `json:"description"`
|
||||
IsHot bool `json:"is_hot"`
|
||||
Locked bool `json:"locked"`
|
||||
}
|
||||
|
||||
type ToolsListReq struct {
|
||||
g.Meta `path:"/tools/list" method:"get" tags:"user" summary:"工具目录(含锁定态)"`
|
||||
}
|
||||
type ToolsListRes struct {
|
||||
Modules []ModuleOut `json:"modules"`
|
||||
List []ToolOut `json:"list"`
|
||||
}
|
||||
|
||||
type ToolsUsedReq struct {
|
||||
g.Meta `path:"/tools/used" method:"post" tags:"user" summary:"工具使用上报"`
|
||||
ToolKey string `v:"required" json:"tool_key"`
|
||||
}
|
||||
type ToolsUsedRes struct{}
|
||||
|
||||
// ===== 工作台 =====
|
||||
|
||||
type WorkbenchGetReq struct {
|
||||
g.Meta `path:"/workbench/get" method:"get" tags:"user" summary:"我的工作台"`
|
||||
}
|
||||
type WorkbenchGetRes struct {
|
||||
ToolKeys []string `json:"tool_keys"`
|
||||
}
|
||||
|
||||
type WorkbenchSaveReq struct {
|
||||
g.Meta `path:"/workbench/save" method:"post" tags:"user" summary:"保存工作台"`
|
||||
ToolKeys []string `v:"required" json:"tool_keys"`
|
||||
}
|
||||
type WorkbenchSaveRes struct{}
|
||||
|
||||
// ===== 反馈 =====
|
||||
|
||||
type FeedbackSubmitReq struct {
|
||||
g.Meta `path:"/feedback/submit" method:"post" tags:"user" summary:"提交反馈"`
|
||||
Content string `v:"required#反馈内容不能为空" json:"content"`
|
||||
Contact string `json:"contact"`
|
||||
}
|
||||
type FeedbackSubmitRes struct{}
|
||||
Reference in New Issue
Block a user