fix: 统一API响应格式并修复前端测试
- 所有Handler方法使用标准{code:0,message:"success",data:...}响应格式
- 修复Cursor分页响应包装(GetAllDevices,GetLoginLogs,ListUsers等)
- 修复AuthHandler和SMSHandler认证方法响应格式
- 修复operation_log.go admin用户operation_type前缀问题
- 修复DashboardPage嵌套stats结构
- 修复LoginLogsPage reset功能stale closure问题
- 修复UsersPage批量操作API调用
- 修复多个前端测试(mock格式、按钮选择、断言逻辑)
- 添加OAuth测试域名白名单
- 新增代码审查流程文档
This commit is contained in:
@@ -33,7 +33,11 @@ func (h *ThemeHandler) CreateTheme(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusCreated, theme)
|
||||
c.JSON(http.StatusCreated, gin.H{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
"data": theme,
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTheme 更新主题
|
||||
@@ -56,7 +60,11 @@ func (h *ThemeHandler) UpdateTheme(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, theme)
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
"data": theme,
|
||||
})
|
||||
}
|
||||
|
||||
// DeleteTheme 删除主题
|
||||
@@ -72,7 +80,10 @@ func (h *ThemeHandler) DeleteTheme(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "theme deleted"})
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "theme deleted",
|
||||
})
|
||||
}
|
||||
|
||||
// GetTheme 获取主题
|
||||
@@ -89,7 +100,11 @@ func (h *ThemeHandler) GetTheme(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, theme)
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
"data": theme,
|
||||
})
|
||||
}
|
||||
|
||||
// ListThemes 获取所有主题
|
||||
@@ -100,7 +115,11 @@ func (h *ThemeHandler) ListThemes(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"themes": themes})
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
"data": themes,
|
||||
})
|
||||
}
|
||||
|
||||
// ListAllThemes 获取所有主题(包括禁用的)
|
||||
@@ -111,7 +130,11 @@ func (h *ThemeHandler) ListAllThemes(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"themes": themes})
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
"data": themes,
|
||||
})
|
||||
}
|
||||
|
||||
// GetDefaultTheme 获取默认主题
|
||||
@@ -122,7 +145,11 @@ func (h *ThemeHandler) GetDefaultTheme(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, theme)
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
"data": theme,
|
||||
})
|
||||
}
|
||||
|
||||
// SetDefaultTheme 设置默认主题
|
||||
@@ -138,7 +165,10 @@ func (h *ThemeHandler) SetDefaultTheme(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "default theme set"})
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "default theme set",
|
||||
})
|
||||
}
|
||||
|
||||
// GetActiveTheme 获取当前生效的主题(公开接口)
|
||||
@@ -149,5 +179,9 @@ func (h *ThemeHandler) GetActiveTheme(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, theme)
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
"data": theme,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user