Commit Graph

7 Commits

Author SHA1 Message Date
b8e9af001f refactor: 提取公共分页解析函数 parsePageAndSize
- 新增 internal/api/handler/common.go 存放 handler 层公共辅助函数
- parsePageAndSize: 统一提取 page/page_size 参数解析、默认值设置、ClampPageSize 调用
- device/log/webhook handler: 替换重复的分页解析代码为 parsePageAndSize 调用
- 清理不再需要的 strconv/pagination 导入
2026-05-08 12:48:03 +08:00
b3374dccf4 refactor: 使用 pagination.ClampPageSize 简化 handler 分页代码
- device/log/webhook handler: 替换 if/else 分页限制为 ClampPageSize
- 统一添加 page < 1 检查(device/log handler 缺失)
2026-05-08 12:45:56 +08:00
1f7a223768 refactor: 提取分页魔法数字为 pagination 常量
- handler 层: device/log/webhook/user handler 使用 pagination.DefaultPageSize/MaxPageSize
- service 层: device/login_log/operation_log service 使用 pagination.DefaultPageSize
- repository 层: user repository 使用 pagination.DefaultPageSize/MaxPageSize
- 消除 8 处硬编码的 20/100 分页魔法数字
2026-05-08 12:40:36 +08:00
84d9ed28af docs: add Swagger annotations to 5 handlers
Add comprehensive Swagger/Swagger comments to:
- export_handler.go (ExportUsers, ImportUsers, GetImportTemplate)
- sms_handler.go (SendCode, LoginByCode)
- sso_handler.go (Authorize, Token, Introspect, Revoke, UserInfo)
- theme_handler.go (8 endpoints)
- webhook_handler.go (5 endpoints)

All 18 handlers now have Swagger annotations.
2026-04-11 22:49:13 +08:00
e00af0bce4 fix: unify handler response format in log, permission, webhook handlers
- log_handler.go: Fix GetMyLoginLogs/GetMyOperationLogs/GetLoginLogs/GetOperationLogs to use {code, message, data}
- permission_handler.go: Fix all error responses to use {code, message}
- webhook_handler.go: Add missing "message" field in success responses, wrap data in data object with list/total/page/page_size
- webhook_handler_test.go: Update test to match new response format

Standardize all JSON responses to {code: 0, message: "success", data: ...} for success
and {code: XXX, message: "..."} for errors.
2026-04-11 13:12:27 +08:00
a85d822419 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测试域名白名单
- 新增代码审查流程文档
2026-04-08 20:06:54 +08:00
dcc1f186f8 feat: backend core - auth, user, role, permission, device, webhook, monitoring, cache, repository, service, middleware, API handlers 2026-04-02 11:19:50 +08:00