Merge pull request #3869 from Birditch/feat/admin-user-role-and-token-ranking

feat(admin): 用户角色管理 + 用户 Token 排行
This commit is contained in:
Wesley Liddick
2026-07-09 19:50:01 +08:00
committed by GitHub
18 changed files with 423 additions and 17 deletions
@@ -164,13 +164,16 @@ type UserSpendingRankingResponse struct {
// UserBreakdownItem represents per-user usage breakdown within a dimension (group, model, endpoint).
type UserBreakdownItem struct {
UserID int64 `json:"user_id"`
Email string `json:"email"`
Requests int64 `json:"requests"`
TotalTokens int64 `json:"total_tokens"`
Cost float64 `json:"cost"` // 标准计费
ActualCost float64 `json:"actual_cost"` // 实际扣除
AccountCost float64 `json:"account_cost"` // 账号成本
UserID int64 `json:"user_id"`
Email string `json:"email"`
Requests int64 `json:"requests"`
InputTokens int64 `json:"input_tokens"` // 输入 token 累计
OutputTokens int64 `json:"output_tokens"` // 输出 token 累计
CacheTokens int64 `json:"cache_tokens"` // 缓存创建 + 读取 token 累计
TotalTokens int64 `json:"total_tokens"` // 输入+输出+缓存 token 累计
Cost float64 `json:"cost"` // 标准计费
ActualCost float64 `json:"actual_cost"` // 实际扣除
AccountCost float64 `json:"account_cost"` // 账号成本
}
// UserBreakdownDimension specifies the dimension to filter for user breakdown.
@@ -187,6 +190,8 @@ type UserBreakdownDimension struct {
RequestType *int16 // filter by request_type (non-nil to enable)
Stream *bool // filter by stream flag (non-nil to enable)
BillingType *int8 // filter by billing_type (non-nil to enable)
// SortBy 指定排序列(空 = 默认按 actual_cost)。合法值由 repo 层 allowlist 校验。
SortBy string
}
// APIKeyUsageTrendPoint represents API key usage trend data point