Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
1e1f3c0c
Commit
1e1f3c0c
authored
Dec 20, 2025
by
Forest
Browse files
ci(backend): 添加 gofmt 配置
parent
1fab9204
Changes
24
Hide whitespace changes
Inline
Side-by-side
backend/internal/service/pricing_service.go
View file @
1e1f3c0c
...
...
@@ -515,11 +515,11 @@ func (s *PricingService) matchByModelFamily(model string) *LiteLLMModelPricing {
}
// GetStatus 获取服务状态
func
(
s
*
PricingService
)
GetStatus
()
map
[
string
]
interface
{}
{
func
(
s
*
PricingService
)
GetStatus
()
map
[
string
]
any
{
s
.
mu
.
RLock
()
defer
s
.
mu
.
RUnlock
()
return
map
[
string
]
interface
{}
{
return
map
[
string
]
any
{
"model_count"
:
len
(
s
.
pricingData
),
"last_updated"
:
s
.
lastUpdated
,
"local_hash"
:
s
.
localHash
[
:
min
(
8
,
len
(
s
.
localHash
))],
...
...
backend/internal/service/redeem_service.go
View file @
1e1f3c0c
...
...
@@ -359,12 +359,12 @@ func (s *RedeemService) Delete(ctx context.Context, id int64) error {
}
// GetStats 获取兑换码统计信息
func
(
s
*
RedeemService
)
GetStats
(
ctx
context
.
Context
)
(
map
[
string
]
interface
{}
,
error
)
{
func
(
s
*
RedeemService
)
GetStats
(
ctx
context
.
Context
)
(
map
[
string
]
any
,
error
)
{
// TODO: 实现统计逻辑
// 统计未使用、已使用的兑换码数量
// 统计总面值等
stats
:=
map
[
string
]
interface
{}
{
stats
:=
map
[
string
]
any
{
"total_codes"
:
0
,
"unused_codes"
:
0
,
"used_codes"
:
0
,
...
...
backend/internal/service/token_refresher.go
View file @
1e1f3c0c
...
...
@@ -19,7 +19,7 @@ type TokenRefresher interface {
// Refresh 执行token刷新,返回更新后的credentials
// 注意:返回的map应该保留原有credentials中的所有字段,只更新token相关字段
Refresh
(
ctx
context
.
Context
,
account
*
model
.
Account
)
(
map
[
string
]
interface
{}
,
error
)
Refresh
(
ctx
context
.
Context
,
account
*
model
.
Account
)
(
map
[
string
]
any
,
error
)
}
// ClaudeTokenRefresher 处理Anthropic/Claude OAuth token刷新
...
...
@@ -61,14 +61,14 @@ func (r *ClaudeTokenRefresher) NeedsRefresh(account *model.Account, refreshWindo
// Refresh 执行token刷新
// 保留原有credentials中的所有字段,只更新token相关字段
func
(
r
*
ClaudeTokenRefresher
)
Refresh
(
ctx
context
.
Context
,
account
*
model
.
Account
)
(
map
[
string
]
interface
{}
,
error
)
{
func
(
r
*
ClaudeTokenRefresher
)
Refresh
(
ctx
context
.
Context
,
account
*
model
.
Account
)
(
map
[
string
]
any
,
error
)
{
tokenInfo
,
err
:=
r
.
oauthService
.
RefreshAccountToken
(
ctx
,
account
)
if
err
!=
nil
{
return
nil
,
err
}
// 保留现有credentials中的所有字段
newCredentials
:=
make
(
map
[
string
]
interface
{}
)
newCredentials
:=
make
(
map
[
string
]
any
)
for
k
,
v
:=
range
account
.
Credentials
{
newCredentials
[
k
]
=
v
}
...
...
backend/internal/service/usage_service.go
View file @
1e1f3c0c
...
...
@@ -195,7 +195,7 @@ func (s *UsageService) GetStatsByModel(ctx context.Context, modelName string, st
}
// GetDailyStats 获取每日使用统计(最近N天)
func
(
s
*
UsageService
)
GetDailyStats
(
ctx
context
.
Context
,
userID
int64
,
days
int
)
([]
map
[
string
]
interface
{}
,
error
)
{
func
(
s
*
UsageService
)
GetDailyStats
(
ctx
context
.
Context
,
userID
int64
,
days
int
)
([]
map
[
string
]
any
,
error
)
{
endTime
:=
time
.
Now
()
startTime
:=
endTime
.
AddDate
(
0
,
0
,
-
days
)
...
...
@@ -227,13 +227,13 @@ func (s *UsageService) GetDailyStats(ctx context.Context, userID int64, days int
}
// 计算平均值并转换为数组
result
:=
make
([]
map
[
string
]
interface
{}
,
0
,
len
(
dailyStats
))
result
:=
make
([]
map
[
string
]
any
,
0
,
len
(
dailyStats
))
for
date
,
stats
:=
range
dailyStats
{
if
stats
.
TotalRequests
>
0
{
stats
.
AverageDurationMs
/=
float64
(
stats
.
TotalRequests
)
}
result
=
append
(
result
,
map
[
string
]
interface
{}
{
result
=
append
(
result
,
map
[
string
]
any
{
"date"
:
date
,
"total_requests"
:
stats
.
TotalRequests
,
"total_input_tokens"
:
stats
.
TotalInputTokens
,
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment