package app import ( "git.echol.cn/loser/st/server/global" "time" ) // AIUsageStat AI 使用统计表 type AIUsageStat struct { global.GVA_MODEL UserID uint `json:"userId" gorm:"not null;index:idx_user_stat,unique;comment:用户ID"` User *AppUser `json:"user" gorm:"foreignKey:UserID"` StatDate time.Time `json:"statDate" gorm:"type:date;not null;index:idx_user_stat,unique;comment:统计日期"` ProviderName string `json:"providerName" gorm:"type:varchar(100);index:idx_user_stat,unique;comment:AI提供商"` ModelName string `json:"modelName" gorm:"type:varchar(200);index:idx_user_stat,unique;comment:模型名称"` RequestCount int `json:"requestCount" gorm:"default:0;comment:请求次数"` TotalTokens int64 `json:"totalTokens" gorm:"default:0;comment:总Token使用量"` PromptTokens int64 `json:"promptTokens" gorm:"default:0;comment:提示词Token使用量"` CompletionTokens int64 `json:"completionTokens" gorm:"default:0;comment:补全Token使用量"` Cost float64 `json:"cost" gorm:"type:decimal(10,4);default:0;comment:费用"` } func (AIUsageStat) TableName() string { return "ai_usage_stats" }