fix: admin handlers 添加 DTO 转换修复 JSON 序列化
修复 PR #36 合并后部分 admin handler 直接返回 service 层对象导致 JSON 字段名为 PascalCase 而非期望的 snake_case 问题。 修复内容: - account_handler: Refresh 接口添加 dto.AccountFromService - openai_oauth_handler: RefreshAccountToken/CreateAccountFromOAuth 添加 dto 转换 - subscription_handler: BulkAssign 添加 dto.BulkAssignResultFromService - usage_handler: List 接口添加 dto.UsageLogFromService 转换 - 新增 dto.BulkAssignResult 类型和对应的 mapper 函数
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/Wei-Shaw/sub2api/internal/handler/dto"
|
||||
"github.com/Wei-Shaw/sub2api/internal/pkg/pagination"
|
||||
"github.com/Wei-Shaw/sub2api/internal/pkg/response"
|
||||
"github.com/Wei-Shaw/sub2api/internal/pkg/timezone"
|
||||
@@ -94,7 +95,11 @@ func (h *UsageHandler) List(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
response.Paginated(c, records, result.Total, page, pageSize)
|
||||
out := make([]dto.UsageLog, 0, len(records))
|
||||
for i := range records {
|
||||
out = append(out, *dto.UsageLogFromService(&records[i]))
|
||||
}
|
||||
response.Paginated(c, out, result.Total, page, pageSize)
|
||||
}
|
||||
|
||||
// Stats handles getting usage statistics with filters
|
||||
|
||||
Reference in New Issue
Block a user