初始化

This commit is contained in:
2026-09-17 14:42:44 +08:00
commit 7c106b69d2
54 changed files with 2521 additions and 0 deletions

235
api/admin/v1/admin.go Normal file
View File

@@ -0,0 +1,235 @@
package v1
import "github.com/gogf/gf/v2/frame/g"
// ===== 登录 =====
type LoginReq struct {
g.Meta `path:"/login" method:"post" tags:"admin" summary:"管理员登录"`
Account string `v:"required#请输入账号" json:"account"`
Password string `v:"required#请输入密码" json:"password"`
Remember bool `json:"remember"`
}
type LoginRes struct {
Token string `json:"token"`
NickName string `json:"nick_name"`
RoleName string `json:"role_name"`
RoleValue string `json:"role_value"`
}
type MyInfoReq struct {
g.Meta `path:"/user/my-info" method:"get" tags:"admin" summary:"当前管理员信息"`
}
type MyInfoRes struct {
Id int64 `json:"id"`
Account string `json:"account"`
NickName string `json:"nick_name"`
RoleName string `json:"role_name"`
RoleValue string `json:"role_value"`
}
// ===== 用户管理 =====
type AdminUserItem struct {
Id int64 `json:"id"`
Nickname string `json:"nickname"`
AvatarUrl string `json:"avatar_url"`
Openid string `json:"openid"`
LevelKey string `json:"level_key"`
LevelName string `json:"level_name"`
Status int `json:"status"`
UsageCount int64 `json:"usage_count"`
LastUsedAt string `json:"last_used_at"`
CreatedAt string `json:"created_at"`
}
type UserListReq struct {
g.Meta `path:"/user/list" method:"get" tags:"admin" summary:"用户列表"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
Keyword string `json:"keyword"`
}
type UserListRes struct {
List []AdminUserItem `json:"list"`
Total int `json:"total"`
}
type UserSetLevelReq struct {
g.Meta `path:"/user/set-level" method:"post" tags:"admin" summary:"设置用户等级"`
UserId int64 `v:"required" json:"userId"`
LevelKey string `v:"required" json:"levelKey"`
}
type UserSetLevelRes struct{}
type UserStatusReq struct {
g.Meta `path:"/user/status" method:"post" tags:"admin" summary:"启停用户"`
UserId int64 `v:"required" json:"userId"`
Status int `json:"status"`
}
type UserStatusRes struct{}
// ===== 等级管理 =====
type LevelItem struct {
Id int64 `json:"id"`
LevelKey string `json:"level_key"`
Name string `json:"name"`
Modules []string `json:"modules"`
Sort int `json:"sort"`
IsEnabled int `json:"is_enabled"`
Remark string `json:"remark"`
}
type LevelListReq struct {
g.Meta `path:"/level/list" method:"get" tags:"admin" summary:"等级列表"`
}
type LevelListRes struct {
List []LevelItem `json:"list"`
}
type LevelSaveReq struct {
g.Meta `path:"/level/save" method:"post" tags:"admin" summary:"保存等级"`
Id int64 `json:"id"`
LevelKey string `v:"required-if:id,0#等级标识不能为空" json:"levelKey"`
Name string `v:"required#等级名称不能为空" json:"name"`
Modules []string `v:"required#至少勾选一个模块" json:"modules"`
Sort int `json:"sort"`
IsEnabled int `json:"isEnabled"`
Remark string `json:"remark"`
}
type LevelSaveRes struct{}
// ===== 模块管理 =====
type ModuleItem struct {
Id int64 `json:"id"`
ModuleKey string `json:"module_key"`
Name string `json:"name"`
Icon string `json:"icon"`
Description string `json:"description"`
Sort int `json:"sort"`
IsEnabled int `json:"is_enabled"`
ToolCount int `json:"tool_count"`
}
type ModuleListReq struct {
g.Meta `path:"/module/list" method:"get" tags:"admin" summary:"模块列表"`
}
type ModuleListRes struct {
List []ModuleItem `json:"list"`
}
type ModuleSaveReq struct {
g.Meta `path:"/module/save" method:"post" tags:"admin" summary:"保存模块"`
Id int64 `json:"id"`
ModuleKey string `v:"required-if:id,0#模块标识不能为空" json:"moduleKey"`
Name string `v:"required#模块名称不能为空" json:"name"`
Icon string `json:"icon"`
Description string `json:"description"`
Sort int `json:"sort"`
IsEnabled int `json:"isEnabled"`
}
type ModuleSaveRes struct{}
// ===== 工具管理 =====
type AdminToolItem struct {
Id int64 `json:"id"`
ToolKey string `json:"tool_key"`
ModuleKey string `json:"module_key"`
ModuleName string `json:"module_name"`
Name string `json:"name"`
Icon string `json:"icon"`
Description string `json:"description"`
Sort int `json:"sort"`
IsEnabled int `json:"is_enabled"`
IsHot int `json:"is_hot"`
UsageCount int64 `json:"usage_count"`
}
type ToolsListReq struct {
g.Meta `path:"/tools/all" method:"get" tags:"admin" summary:"工具列表(全量)"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
ModuleKey string `json:"moduleKey"`
Keyword string `json:"keyword"`
IncludeDisabled bool `json:"includeDisabled"`
}
type ToolsListRes struct {
List []AdminToolItem `json:"list"`
Total int `json:"total"`
}
type ToolsSaveReq struct {
g.Meta `path:"/tools/save" method:"post" tags:"admin" summary:"保存工具"`
Id int64 `json:"id"`
ToolKey string `v:"required-if:id,0#工具标识不能为空" json:"toolKey"`
ModuleKey string `v:"required#所属模块不能为空" json:"moduleKey"`
Name string `v:"required#工具名称不能为空" json:"name"`
Icon string `json:"icon"`
Description string `json:"description"`
Sort int `json:"sort"`
IsEnabled int `json:"isEnabled"`
IsHot int `json:"isHot"`
}
type ToolsSaveRes struct{}
type ToolsToggleReq struct {
g.Meta `path:"/tools/toggle" method:"post" tags:"admin" summary:"工具开关"`
Id int64 `v:"required" json:"id"`
Field string `v:"required|in:is_enabled,is_hot" json:"field"`
Value int `json:"value"`
}
type ToolsToggleRes struct{}
// ===== 数据看板 =====
type TrendItem struct {
Date string `json:"date"`
Count int64 `json:"count"`
}
type TopItem struct {
ToolKey string `json:"tool_key"`
Name string `json:"name"`
Count int64 `json:"count"`
}
type DashboardStatsReq struct {
g.Meta `path:"/dashboard/stats" method:"get" tags:"admin" summary:"看板统计"`
}
type DashboardStatsRes struct {
UserCount int64 `json:"userCount"`
TodayActive int64 `json:"todayActive"`
TotalUsage int64 `json:"totalUsage"`
WeekTrend []TrendItem `json:"weekTrend"`
ToolsTop []TopItem `json:"toolsTop"`
}
// ===== 反馈管理 =====
type FeedbackItem struct {
Id int64 `json:"id"`
UserId int64 `json:"user_id"`
Content string `json:"content"`
Contact string `json:"contact"`
Status int `json:"status"`
CreatedAt string `json:"created_at"`
}
type FeedbackListReq struct {
g.Meta `path:"/feedback/list" method:"get" tags:"admin" summary:"反馈列表"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
Status *int `json:"status"`
}
type FeedbackListRes struct {
List []FeedbackItem `json:"list"`
Total int `json:"total"`
}
type FeedbackHandleReq struct {
g.Meta `path:"/feedback/handle" method:"post" tags:"admin" summary:"标记已处理"`
Id int64 `v:"required" json:"id"`
}
type FeedbackHandleRes struct{}

148
api/user/v1/user.go Normal file
View 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{}