- 全局替换 ApiKey → APIKey(类型、字段、方法、变量) - 修复所有 initialism 命名(API, SMTP, HTML, URL 等) - 添加所有缺失的包注释 - 修复导出符号的注释格式 主要修改: - ApiKey → APIKey(所有出现的地方) - ApiKeyID → APIKeyID - ApiKeyIDs → APIKeyIDs - TestSmtpConnection → TestSMTPConnection - HtmlURL → HTMLURL - 添加 20+ 个包注释 - 修复 10+ 个导出符号注释格式 验证结果: - ✓ golangci-lint: 0 issues - ✓ 单元测试: 通过 - ✓ 集成测试: 通过
54 lines
1008 B
Go
54 lines
1008 B
Go
package service
|
|
|
|
import "time"
|
|
|
|
const (
|
|
BillingTypeBalance int8 = 0 // 钱包余额
|
|
BillingTypeSubscription int8 = 1 // 订阅套餐
|
|
)
|
|
|
|
type UsageLog struct {
|
|
ID int64
|
|
UserID int64
|
|
APIKeyID int64
|
|
AccountID int64
|
|
RequestID string
|
|
Model string
|
|
|
|
GroupID *int64
|
|
SubscriptionID *int64
|
|
|
|
InputTokens int
|
|
OutputTokens int
|
|
CacheCreationTokens int
|
|
CacheReadTokens int
|
|
|
|
CacheCreation5mTokens int
|
|
CacheCreation1hTokens int
|
|
|
|
InputCost float64
|
|
OutputCost float64
|
|
CacheCreationCost float64
|
|
CacheReadCost float64
|
|
TotalCost float64
|
|
ActualCost float64
|
|
RateMultiplier float64
|
|
|
|
BillingType int8
|
|
Stream bool
|
|
DurationMs *int
|
|
FirstTokenMs *int
|
|
|
|
CreatedAt time.Time
|
|
|
|
User *User
|
|
APIKey *APIKey
|
|
Account *Account
|
|
Group *Group
|
|
Subscription *UserSubscription
|
|
}
|
|
|
|
func (u *UsageLog) TotalTokens() int {
|
|
return u.InputTokens + u.OutputTokens + u.CacheCreationTokens + u.CacheReadTokens
|
|
}
|