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:
2026-04-08 20:06:54 +08:00
parent 26c5def4d7
commit a85d822419
33 changed files with 2108 additions and 206 deletions

View File

@@ -58,7 +58,11 @@ func (h *AuthHandler) Register(c *gin.Context) {
return
}
c.JSON(http.StatusCreated, userInfo)
c.JSON(http.StatusCreated, gin.H{
"code": 0,
"message": "success",
"data": userInfo,
})
}
func (h *AuthHandler) Login(c *gin.Context) {
@@ -98,7 +102,11 @@ func (h *AuthHandler) Login(c *gin.Context) {
return
}
c.JSON(http.StatusOK, resp)
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "success",
"data": resp,
})
}
func (h *AuthHandler) Logout(c *gin.Context) {
@@ -144,7 +152,11 @@ func (h *AuthHandler) RefreshToken(c *gin.Context) {
return
}
c.JSON(http.StatusOK, resp)
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "success",
"data": resp,
})
}
func (h *AuthHandler) GetUserInfo(c *gin.Context) {
@@ -160,7 +172,11 @@ func (h *AuthHandler) GetUserInfo(c *gin.Context) {
return
}
c.JSON(http.StatusOK, userInfo)
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "success",
"data": userInfo,
})
}
func (h *AuthHandler) GetCSRFToken(c *gin.Context) {
@@ -283,7 +299,11 @@ func (h *AuthHandler) LoginByEmailCode(c *gin.Context) {
}()
}
c.JSON(http.StatusOK, resp)
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "success",
"data": resp,
})
}
func (h *AuthHandler) BootstrapAdmin(c *gin.Context) {
@@ -330,7 +350,11 @@ func (h *AuthHandler) BootstrapAdmin(c *gin.Context) {
return
}
c.JSON(http.StatusCreated, resp)
c.JSON(http.StatusCreated, gin.H{
"code": 0,
"message": "success",
"data": resp,
})
}
func (h *AuthHandler) SendEmailBindCode(c *gin.Context) {