- 添加用户认证模块 (JWT + 密码管理) - 添加 ChatGPT 账户管理功能 - 添加卡密管理功能 (创建、批量生成、查询) - 添加邀请功能 - 配置数据库迁移和路由系统
26 lines
689 B
Go
26 lines
689 B
Go
package models
|
|
|
|
import (
|
|
"database/sql"
|
|
"time"
|
|
)
|
|
|
|
// APIKey API 密钥表
|
|
type APIKey struct {
|
|
ID int `json:"id"`
|
|
Key string `json:"key"` // 格式: sk_live_xxx
|
|
Name string `json:"name"`
|
|
CreatedByID int `json:"created_by_id"`
|
|
IsActive bool `json:"is_active"`
|
|
RateLimit int `json:"rate_limit"` // 次/分钟
|
|
AllowedIPs string `json:"allowed_ips"` // JSON 数组
|
|
LastUsed sql.NullTime `json:"last_used"`
|
|
RequestCount int `json:"request_count"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// TableName 返回表名
|
|
func (APIKey) TableName() string {
|
|
return "api_keys"
|
|
}
|