fix(response):修复响应结构错误问题
This commit is contained in:
1 parent
4889477452
commit
22bdb23c8d
21 files changed
+208
-65
No files matched your search
@@ -1,6 +1,10 @@
|
||||
package v1
|
||||
|
||||
import "github.com/gogf/gf/v2/frame/g"
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// 渠道调试日志:调试开关开启的渠道,per-attempt 记录客户端↔系统↔上游四段完整报文。
|
||||
// 端点全部为 GET/DELETE,路径在 /channels/ 下,自动命中 rbac 前缀规则
|
||||
@@ -50,9 +54,14 @@ type ChannelDebugLogDetailReq struct {
|
||||
ID int64 `json:"id" in:"path" v:"required" dc:"记录ID"`
|
||||
}
|
||||
|
||||
// ChannelDebugLogDetailRes 渠道调试日志详情响应
|
||||
// ChannelDebugLogDetailRes 渠道调试日志详情响应:详情对象平铺进统一响应的 data 字段
|
||||
// (json:"-" + 自定义 MarshalJSON),避免统一包装后再多包一层 data
|
||||
type ChannelDebugLogDetailRes struct {
|
||||
Data map[string]any `json:"data"`
|
||||
Data map[string]any `json:"-"`
|
||||
}
|
||||
|
||||
func (r *ChannelDebugLogDetailRes) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(r.Data)
|
||||
}
|
||||
|
||||
// ChannelDebugLogDeleteReq 删除单条调试日志请求(硬删除)
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package v1
|
||||
|
||||
import "github.com/gogf/gf/v2/frame/g"
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// === 渠道错误监控 ===
|
||||
|
||||
@@ -61,8 +65,14 @@ type ChannelErrorCategoriesReq struct {
|
||||
g.Meta `path:"/monitor/channel-errors/categories" method:"get" mime:"json" tags:"管理后台-监控" summary:"错误分类选项"`
|
||||
}
|
||||
|
||||
// ChannelErrorCategoriesRes 分类选项平铺进统一响应的 data 字段(json:"-" + 自定义
|
||||
// MarshalJSON),避免统一包装后再多包一层 data
|
||||
type ChannelErrorCategoriesRes struct {
|
||||
Data []map[string]string `json:"data"`
|
||||
Data []map[string]string `json:"-"`
|
||||
}
|
||||
|
||||
func (r *ChannelErrorCategoriesRes) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(r.Data)
|
||||
}
|
||||
|
||||
// ChannelErrorClearReq 清空全部渠道错误事件(硬删除,用于错误大量堆积时快速释放数据库空间)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
@@ -142,6 +144,54 @@ type AdminUsageLogListReq struct {
|
||||
AdminUsageLogFilter `json:",inline"` // 嵌入共用筛选条件
|
||||
}
|
||||
|
||||
// AdminUsageLogListItem 用量日志列表项:仅表格列与悬浮明细(Token / 费用分解)所需字段。
|
||||
// 纯关联 ID(user_id / project_id / channel_id)与排查大字段(billing_snapshot、
|
||||
// user_agent、error_message、request_id 等)不进列表,统一经详情接口按需获取。
|
||||
type AdminUsageLogListItem struct {
|
||||
Id int64 `json:"id"`
|
||||
TenantId int64 `json:"tenant_id"`
|
||||
TenantName string `json:"tenant_name"`
|
||||
Username string `json:"username"`
|
||||
ProjectName string `json:"project_name"`
|
||||
ApiKeyId int64 `json:"api_key_id"`
|
||||
ApiKeyName string `json:"api_key_name"`
|
||||
ChannelName string `json:"channel_name"`
|
||||
ModelName string `json:"model_name"`
|
||||
UpstreamModel string `json:"upstream_model"`
|
||||
RequestType int `json:"request_type"`
|
||||
BillingMode string `json:"billing_mode"`
|
||||
InputTokens int `json:"input_tokens"`
|
||||
OutputTokens int `json:"output_tokens"`
|
||||
CacheCreationTokens int `json:"cache_creation_tokens"`
|
||||
CacheReadTokens int `json:"cache_read_tokens"`
|
||||
CacheCreation5mTokens int `json:"cache_creation_5m_tokens"`
|
||||
CacheCreation1hTokens int `json:"cache_creation_1h_tokens"`
|
||||
ReasoningTokens int `json:"reasoning_tokens"`
|
||||
AudioInputTokens int `json:"audio_input_tokens"`
|
||||
AudioOutputTokens int `json:"audio_output_tokens"`
|
||||
ImageOutputTokens int `json:"image_output_tokens"`
|
||||
InputCost float64 `json:"input_cost"`
|
||||
OutputCost float64 `json:"output_cost"`
|
||||
CacheCreationCost float64 `json:"cache_creation_cost"`
|
||||
CacheReadCost float64 `json:"cache_read_cost"`
|
||||
TotalCost float64 `json:"total_cost"`
|
||||
ActualCost float64 `json:"actual_cost"`
|
||||
RateMultiplier float64 `json:"rate_multiplier"`
|
||||
LatencyMs int `json:"latency_ms"`
|
||||
FirstTokenMs int `json:"first_token_ms"`
|
||||
Status string `json:"status"`
|
||||
RetryIndex int `json:"retry_index"`
|
||||
CreatedAt *gtime.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type AdminUsageLogListRes struct {
|
||||
List []*AdminUsageLogListItem `json:"list"`
|
||||
Total int `json:"total"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// AdminUsageLogItem 用量日志全量字段结构体(详情接口专用,列表用上方的精简 ListItem)
|
||||
type AdminUsageLogItem struct {
|
||||
Id int64 `json:"id"`
|
||||
TenantId int64 `json:"tenant_id"`
|
||||
@@ -204,13 +254,6 @@ type AdminUsageLogItem struct {
|
||||
CreatedAt *gtime.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type AdminUsageLogListRes struct {
|
||||
List []*AdminUsageLogItem `json:"list"`
|
||||
Total int `json:"total"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// AdminUsageLogDetailReq 用量日志详情(列表只返回表格展示字段,
|
||||
// billing_snapshot / billing_summary / user_agent / error_message 等大字段经此接口按需获取)
|
||||
type AdminUsageLogDetailReq struct {
|
||||
@@ -218,8 +261,14 @@ type AdminUsageLogDetailReq struct {
|
||||
Id int64 `json:"id" in:"path" v:"min:1" dc:"用量记录ID"`
|
||||
}
|
||||
|
||||
// AdminUsageLogDetailRes 详情对象平铺进统一响应的 data 字段(json:"-" + 自定义 MarshalJSON,
|
||||
// 与 RequestAuditLogDetailRes 同一模式),避免统一包装后再多包一层 data
|
||||
type AdminUsageLogDetailRes struct {
|
||||
Data *AdminUsageLogItem `json:"data"`
|
||||
Data *AdminUsageLogItem `json:"-"`
|
||||
}
|
||||
|
||||
func (r *AdminUsageLogDetailRes) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(r.Data)
|
||||
}
|
||||
|
||||
// AdminUsageLogSummaryReq 用量日志统计请求(复用筛选条件,不包含分页)
|
||||
|
||||
@@ -58,8 +58,14 @@ type ErrorLogStatsReq struct {
|
||||
g.Meta `path:"/error-logs/stats" method:"get" mime:"json" tags:"管理后台-系统错误" summary:"错误统计"`
|
||||
}
|
||||
|
||||
// ErrorLogStatsRes 统计对象平铺进统一响应的 data 字段(json:"-" + 自定义 MarshalJSON),
|
||||
// 避免统一包装后再多包一层 data
|
||||
type ErrorLogStatsRes struct {
|
||||
Data map[string]any `json:"data"`
|
||||
Data map[string]any `json:"-"`
|
||||
}
|
||||
|
||||
func (r *ErrorLogStatsRes) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(r.Data)
|
||||
}
|
||||
|
||||
// ErrorLogClearReq 清空全部错误日志(硬删除,用于错误大量堆积时快速释放数据库空间)
|
||||
|
||||
+42
-8
@@ -1,6 +1,10 @@
|
||||
package v1
|
||||
|
||||
import "github.com/gogf/gf/v2/frame/g"
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// === 监控仪表盘 ===
|
||||
|
||||
@@ -9,8 +13,14 @@ type MonitorDashboardReq struct {
|
||||
Minutes int `json:"minutes" in:"query" d:"5"`
|
||||
}
|
||||
|
||||
// MonitorDashboardRes 数据对象平铺进统一响应的 data 字段(json:"-" + 自定义 MarshalJSON),
|
||||
// 避免统一包装后再多包一层 data(monitor 包下带 Data 的 Res 均为此模式)
|
||||
type MonitorDashboardRes struct {
|
||||
Data map[string]any `json:"data"`
|
||||
Data map[string]any `json:"-"`
|
||||
}
|
||||
|
||||
func (r *MonitorDashboardRes) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(r.Data)
|
||||
}
|
||||
|
||||
type MonitorTrafficReq struct {
|
||||
@@ -19,7 +29,11 @@ type MonitorTrafficReq struct {
|
||||
}
|
||||
|
||||
type MonitorTrafficRes struct {
|
||||
Data any `json:"data"`
|
||||
Data any `json:"-"`
|
||||
}
|
||||
|
||||
func (r *MonitorTrafficRes) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(r.Data)
|
||||
}
|
||||
|
||||
type MonitorTrafficFlowReq struct {
|
||||
@@ -30,7 +44,11 @@ type MonitorTrafficFlowReq struct {
|
||||
}
|
||||
|
||||
type MonitorTrafficFlowRes struct {
|
||||
Data any `json:"data"`
|
||||
Data any `json:"-"`
|
||||
}
|
||||
|
||||
func (r *MonitorTrafficFlowRes) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(r.Data)
|
||||
}
|
||||
|
||||
type MonitorModelPerformanceReq struct {
|
||||
@@ -102,7 +120,11 @@ type MonitorLatencyReq struct {
|
||||
}
|
||||
|
||||
type MonitorLatencyRes struct {
|
||||
Data map[string]any `json:"data"`
|
||||
Data map[string]any `json:"-"`
|
||||
}
|
||||
|
||||
func (r *MonitorLatencyRes) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(r.Data)
|
||||
}
|
||||
|
||||
type MonitorSystemReq struct {
|
||||
@@ -111,7 +133,11 @@ type MonitorSystemReq struct {
|
||||
}
|
||||
|
||||
type MonitorSystemRes struct {
|
||||
Data map[string]any `json:"data"`
|
||||
Data map[string]any `json:"-"`
|
||||
}
|
||||
|
||||
func (r *MonitorSystemRes) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(r.Data)
|
||||
}
|
||||
|
||||
// MonitorDispatchReq 渠道调度引擎指标请求
|
||||
@@ -176,7 +202,11 @@ type MonitorRealtimeReq struct {
|
||||
}
|
||||
|
||||
type MonitorRealtimeRes struct {
|
||||
Data any `json:"data"`
|
||||
Data any `json:"-"`
|
||||
}
|
||||
|
||||
func (r *MonitorRealtimeRes) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(r.Data)
|
||||
}
|
||||
|
||||
// === 告警规则 ===
|
||||
@@ -202,7 +232,11 @@ type AlertOptionsReq struct {
|
||||
}
|
||||
|
||||
type AlertOptionsRes struct {
|
||||
Data map[string]any `json:"data"`
|
||||
Data map[string]any `json:"-"`
|
||||
}
|
||||
|
||||
func (r *AlertOptionsRes) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(r.Data)
|
||||
}
|
||||
|
||||
type AlertRuleCreateReq struct {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
@@ -59,8 +61,14 @@ type PlanDetailReq struct {
|
||||
Id int64 `json:"id" in:"path" v:"required|min:1"`
|
||||
}
|
||||
|
||||
// PlanDetailRes 详情对象平铺进统一响应的 data 字段(json:"-" + 自定义 MarshalJSON),
|
||||
// 避免统一包装后再多包一层 data
|
||||
type PlanDetailRes struct {
|
||||
Data *PlanItem `json:"data"`
|
||||
Data *PlanItem `json:"-"`
|
||||
}
|
||||
|
||||
func (r *PlanDetailRes) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(r.Data)
|
||||
}
|
||||
|
||||
type PlanUpdateReq struct {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
@@ -62,6 +64,12 @@ type TenantRequestAuditLogDetailReq struct {
|
||||
Id int64 `json:"id" in:"path" v:"required|min:1"`
|
||||
}
|
||||
|
||||
// TenantRequestAuditLogDetailRes 详情对象平铺进统一响应的 data 字段(json:"-" + 自定义
|
||||
// MarshalJSON),避免统一包装后再多包一层 data(与 admin 端审计详情接口同一模式)
|
||||
type TenantRequestAuditLogDetailRes struct {
|
||||
Data map[string]any `json:"data"`
|
||||
Data map[string]any `json:"-"`
|
||||
}
|
||||
|
||||
func (r *TenantRequestAuditLogDetailRes) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(r.Data)
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package v1
|
||||
|
||||
import "github.com/gogf/gf/v2/frame/g"
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// === 租户用量与账单 ===
|
||||
|
||||
@@ -31,8 +35,14 @@ type TenantUsageLogDetailReq struct {
|
||||
Id int64 `json:"id" in:"path" v:"min:1" dc:"用量记录ID"`
|
||||
}
|
||||
|
||||
// TenantUsageLogDetailRes 详情对象平铺进统一响应的 data 字段(json:"-" + 自定义
|
||||
// MarshalJSON),避免统一包装后再多包一层 data(与 admin 端详情接口同一模式)
|
||||
type TenantUsageLogDetailRes struct {
|
||||
Data map[string]any `json:"data"`
|
||||
Data map[string]any `json:"-"`
|
||||
}
|
||||
|
||||
func (r *TenantUsageLogDetailRes) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(r.Data)
|
||||
}
|
||||
|
||||
// TenantUsageLogsSummaryReq 用量日志统计请求(复用列表筛选条件,不含分页)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
@@ -124,8 +126,14 @@ type TenantProjectUsageStatsReq struct {
|
||||
Id int64 `json:"id" in:"path" v:"required|min:1"`
|
||||
}
|
||||
|
||||
// TenantProjectUsageStatsRes 统计对象平铺进统一响应的 data 字段(json:"-" + 自定义
|
||||
// MarshalJSON),避免统一包装后再多包一层 data
|
||||
type TenantProjectUsageStatsRes struct {
|
||||
Data map[string]any `json:"data"`
|
||||
Data map[string]any `json:"-"`
|
||||
}
|
||||
|
||||
func (r *TenantProjectUsageStatsRes) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(r.Data)
|
||||
}
|
||||
|
||||
type TenantProjectUsageLogsReq struct {
|
||||
|
||||
Reference in new issue
Block a user